@clawhub-eycuit-50b5400772
Integrated on-chain operations hub: integrates BlockBeats market intelligence, Hyperliquid DEX trading via `hl1m`, wallet creation and management at https://...
---
name: 1m-trade
description: |
Integrated on-chain operations hub: integrates BlockBeats market intelligence, Hyperliquid DEX trading via `hl1m`, wallet creation and management at https://www.1m-trade.com, and supports local initialization using `hl1m init-wallet` (wallet address + proxy private key, never use the main wallet private key). Supports fully autonomous AI trading.
metadata:
openclaw:
emoji: "🚀"
always: false
requires:
bins:
- curl
- node
- hl1m
- openclaw
configPaths:
- ~/.openclaw/.1m-trade/.env
- $OPENCLAW_STATE_DIR/.1m-trade/.env
env:
- BLOCKBEATS_API_KEY
- HYPERLIQUID_PRIVATE_KEY_ENC
- HYPERLIQUID_PK_ENC_PASSWORD
- HYPERLIQUID_WALLET_ADDRESS
os:
- darwin
- linux
- win32
tags:
- crypto
- news
- trading
- hyperliquid
- wallet
- dex
- automation
---
# 1m-trade Aggregator - On-chain Operations Hub
**Official website (wallet & account)**: [https://www.1m-trade.com](https://www.1m-trade.com)
## After first install
Scan and verify all required dependencies for sub-skills and install what is needed. From this skill bundle root, run `node auto_check.js` to verify required binaries and `.env` entries (it does not print secrets).
### `1m-trade-news` (required)
This aggregator **must** have the **`1m-trade-news`** sub-skill available: market intelligence, news, and BlockBeats API calls all go through it. Do **not** skip this step when installing the bundle.
1. **Skill files**: Ensure the bundle includes **`skills/1m-trade-news/`** (`SKILL.md`, etc.) and that your OpenClaw / host loads that folder as the **`1m-trade-news`** skill.
2. **`curl`**: Required on `PATH` for the documented API flows (see metadata `requires.bins`).
3. **BlockBeats API key (`BLOCKBEATS_API_KEY`)**: Market and news workflows use the **BlockBeats Pro API**. Install-time, ensure **`BLOCKBEATS_API_KEY`** is set in the local `1m-trade` state file (paths under **Optional runtime override** below).
**Apply for / obtain a key (free tier)**:
1. Request a free API key:
```bash
curl --request GET --url "https://api-pro.theblockbeats.info/v1/api-key/free"
```
2. From the JSON body, read `data.api_key` and use it as `BLOCKBEATS_API_KEY`.
3. Write it to `~/.openclaw/.1m-trade/.env` (or `$OPENCLAW_STATE_DIR/.1m-trade/.env` if you use that override), on its own line:
`BLOCKBEATS_API_KEY=<api_key>`
Do not remove unrelated lines; only add or update this variable.
**Reference**: `skills/1m-trade-news/SKILL.md` → **Get an API key** (includes agent-safe steps to populate `.env` without printing the key).
**Security**: Do not paste API keys into chat; the model must not echo stored keys.
### `1m-trade-dex` (required)
This aggregator **must** have the **`1m-trade-dex`** sub-skill available: trading, wallet queries, and `hl1m` all go through it. Do **not** skip this step when installing the bundle.
1. **Skill files**: Ensure the bundle includes **`skills/1m-trade-dex/`** (`SKILL.md`, `reference.md`, etc.) and that your OpenClaw / host loads that folder as the **`1m-trade-dex`** skill.
2. **CLI (`hl1m`)**: Install the `1m-trade` package so `hl1m` is on `PATH` (Python 3.11+ recommended):
```bash
pipx install 1m-trade
hl1m --help
```
If `pipx` is missing, install it per your OS (see `skills/1m-trade-dex/SKILL.md` → **Setup**).
3. **Wallet / Hyperliquid state**: After install, users still run **`hl1m init-wallet`** (and related steps) so `.env` contains the Hyperliquid fields `auto_check.js` expects — see **`skills/1m-trade-dex/SKILL.md`** → **Wallet initialization**.
Optional runtime override:
- `OPENCLAW_STATE_DIR` can be set to change where local `.1m-trade` state files are read/written.
- If not set, tools default to `~/.openclaw/.1m-trade/`.
Secret source-of-truth policy:
- API key and wallet credentials are expected in the local state `.env` file under the paths above (typically after the user runs `hl1m init-wallet` and related CLIs locally).
- Process environment variables may be used only as explicit runtime overrides by underlying tools.
- **LLM boundary**: The model must **not** read `.env` into context or quote stored secrets. For **wallet bind**, if the user **voluntarily** sends wallet address + **proxy** private key in one message (e.g. clearly labeled fields such as `wallet address` and `proxy private key`), follow `1m-trade-dex` → parse and **invoke** `hl1m init-wallet --address … --pri_key …` in a trusted shell; **do not** repeat full keys in assistant replies. Otherwise prefer the user running `init-wallet` locally without pasting keys in chat.
- Never print secret values in assistant-visible chat or user-facing logs from the model.
## Overview
This skill (`1m-trade`) is an orchestration hub that integrates multiple sub-skills into a single coherent workflow. You describe your goal (e.g., "check today's sentiment", "analyze BTC fund flows and open a long with half my balance", "help me configure my Hyperliquid wallet with init-wallet", "auto-trade BTC"), and this skill decomposes the request and calls `1m-trade-news` and `1m-trade-dex` to complete the operation.
## Core workflows
Based on **intent keywords**, this skill routes into one of the workflows below (or composes them).
### Workflow 1: Market intelligence (Data & News)
**Triggers**: `market`, `price`, `news`, `macro`, `fund flows`, `perps`, `search [keyword]`
**Skill**: `1m-trade-news`
**Logic**:
1. Parse the user query and map it to a scenario / intent mapping.
2. Call the relevant BlockBeats API endpoints in parallel.
3. Format and aggregate results into a market report with brief interpretation.
**Example output**:
```
📰 Market Report · 202X-XX-XX
===
1. 📊 Snapshot
Sentiment: 35 → Neutral
BTC ETF: +$120M net inflow today
On-chain tx volume: +15% vs yesterday
2. 💰 Hot flows (Solana)
1. JTO net inflow $4.2M
2. ...
3. 🌐 Macro
Global M2: +4.5% YoY → Liquidity easing
DXY: 104.2 → Relatively strong
Overall: Macro backdrop is neutral-to-bullish for crypto.
```
### Workflow 2: Wallet setup (initialization)
**Triggers**: `init wallet`, `configure wallet`, `configure trading account`, `bind wallet`, `connect Hyperliquid`, `set up trading`, `wallet settings`, `proxy key`, `API key` (wallet); same message with both `wallet address` and `proxy private key` (or non-English equivalents per `1m-trade-dex` **Natural-language binding**).
**Skill**: `1m-trade-dex` (see `skills/1m-trade-dex/SKILL.md` → **Natural-language binding** and `skills/1m-trade-dex/reference.md`)
**Wallet operations (synced with sub-skill docs)**:
| Step | Where | What |
|------|--------|------|
| Create / manage wallet | Browser | **[https://www.1m-trade.com](https://www.1m-trade.com)** — official UI for account and wallet; do not recreate this flow in chat. |
| Bind CLI to the account | Local shell | **`hl1m init-wallet`** only — **wallet public address** + **proxy (API) private key**. **Never** use the **main / master** wallet private key. |
| Verify | After init | `hl1m query-user-state` (and other `hl1m` query commands as needed). |
**Logic**:
1. Send users to **[https://www.1m-trade.com](https://www.1m-trade.com)** for **wallet creation and ongoing management** in the browser. Do not simulate full wallet creation inside the assistant.
2. For **CLI binding**:
- If the user provides **both** address and proxy key in one message (with labels such as `wallet address` and `proxy private key`, or other languages as mapped in `1m-trade-dex`), follow `1m-trade-dex` **Natural-language binding**: parse `0x` + 40 hex (address) and `0x` + 64 hex (proxy key), then run `hl1m init-wallet --address <parsed> --pri_key <parsed>` in a trusted shell; do not echo full keys in chat.
- Otherwise, show the placeholder command only and ask the user to run locally:
```bash
hl1m init-wallet --address 0xYourWalletAddress --pri_key 0xYourProxyPrivateKey
```
3. After a successful init, use `hl1m query-user-state` to confirm the account is visible.
### Workflow 3: Trading execution & management (Trading & Management)
**Triggers**: `trade`, `order`, `open`, `close`, `positions`, `price`, `kline`, `HIP3`, `AAPL`, `GOLD`
**Skill**: `1m-trade-dex`
**Logic**:
1. **Market data**: query kline/mids/meta as requested and format results.
2. **Pre-trade checks**: ensure `1m-trade-dex` is installed and run `node auto_check.js` to verify prerequisites. If it fails, do not execute any trades.
3. **Execution**: follow the `1m-trade-dex` documentation for the specific command.
### Workflow 4: Hybrid orchestration (Hybrid Workflow)
**Trigger examples**: "check the market then decide whether to buy BTC", "after I init my wallet, show ETH kline"
**Logic**:
1. Call Workflow 1 to fetch the market report.
2. Present the report and ask whether to continue (e.g., "proceed to wallet setup or trading?").
3. After confirmation, call Workflow 2 (wallet init guidance) or Workflow 3.
## Examples
**User**: "How is the crypto market today? I also need to connect my Hyperliquid wallet."
**`1m-trade`**:
1. Generate a market snapshot report (Workflow 1).
2. Point to **[1M-Trade](https://www.1m-trade.com)** for wallet creation/management as needed, then Workflow 2: if the user already sent labeled `wallet address` + `proxy private key` (or equivalent), parse and run `hl1m init-wallet`; otherwise give the placeholder command for local use (proxy key only; never the main wallet private key). Do not guide `send-private-key`.
**User**: "Search for the latest news about 'Bitcoin halving', then show BTC kline."
**`1m-trade`**:
1. Call search (Workflow 1, Scenario 5) and return relevant items.
2. Call kline query (Workflow 3) and return recent candles.
### Workflow 5: Fully autonomous mode (AI Auto-Trader)
**Triggers**: `enable auto trading`, `autonomous trading`, `managed`, `AI trade for me`, `run every N minutes`, `auto trade BTC`
**Logic**:
1. Run the checker once before enabling cron:
- Repo root: `node auto_check.js`
- If installed under the OpenClaw workspace: run `node <skill_bundle_root>/auto_check.js`
If it fails, do not enable auto trading.
2. Check whether the `1m-trade-auto-trader` cron job exists:
- Run `openclaw cron list` to verify whether it still exists.
- If it exists, ask the user to stop/remove it before creating a new one.
- If the user confirms it should be removed and it is still present, attempt to remove it with `openclaw cron rm <task id>`, then re-run `openclaw cron list` to confirm it is gone.
3. Create a periodic workflow using the command below. `--session isolated` is fixed and must not be changed. The default interval is every 20 minutes (`*/20`); replace with `*/N` if needed. Send the trading report to the user.
Security constraints for the cron message:
- Include ONLY the "#### Workflow content" block as the job prompt template.
- Never include any secrets (API keys, private keys, passwords, `.env` contents, tokens).
- Never include unrelated user/system text, terminal logs, or file contents.
- Keep shell commands/placeholders unchanged, but you may translate natural-language instructions for locale.
4. Run:
```bash
openclaw cron add \
--name "1m-trade-auto-trader" \
--cron "*/20 * * * *" \
--session isolated \
--message "<Paste the FULL prompt from #### Workflow content through the end of the report template below; translate EVERY narrative line into the user's language (e.g. full Simplified Chinese if the user uses Chinese—no leftover English instructions). Keep skill names, hl1m subcommands, symbols, and <<...>> structure unchanged. No secrets. Each run outputs ONLY the final trading report; that report must be monolingual (all Chinese OR all English per user—no mixed prose). Replace this placeholder with that translated block.>" \
--timeoutSeconds 600 \
--announce \
--channel <channel e.g. telegram> \
--to "<user id>" \
```
#### Workflow content
Pre-start: dependency memory check
All skills are installed locally.
1. Try reading: `$OPENCLAW_STATE_DIR/.1m-trade/dependencies-status.md`
- If missing → first run, treat as "not confirmed installed"
- If present, look for any marker:
- Installed: true
- DependencyStatus: Installed
- SkillsReady: true
- Record status as "installed" or "not installed/unknown"
2. Decide based on the status:
- If clearly "installed" → skip checks/install and go to step 4
- Otherwise → run step 3
3. Only when initialization is needed:
Ensure these skills are available in order:
- 1m-trade-news
- 1m-trade-dex
If a skill is unavailable, attempt to install/enable it via the system's mechanism.
Then record success in the memory file.
4. Must execute: update/create the dependency memory file by overwriting:
```
# Dependency install marker - do not edit manually
Installed: true
Skills: 1m-trade-news (or others)
Skills Path: <skill paths>
LastChecked: 2026-03-15 14:30:00 UTC
```
Start execution
Start execution.
### Workflow: Fully autonomous trading mode (AI Auto-Trader)
## Execution Guidelines
- Evaluate the full market universe (scan multiple assets). Trades are determined by risk controls; 0 to multiple trades are allowed.
- Output must be a trading report only (no executable code). Markdown tables/quotes are allowed.
- Do not create or modify any files.
- Only call existing skills.
- Use real trading (not simulation).
## Response format
- Your final assistant response must contain only the final trading report section in the required Markdown structure.
- **Language**: The report must be **fully** in one language matching the user (see **Locale** / **Monolingual output** in **#### 4. Trading brief**) — no mixed Chinese/English prose.
---
# Market universe (fixed; do not modify)
- `BTC`
- `ETH`
- `SOL`
- `xyz:GOLD` (alias: Gold)
- `xyz:CL` (alias: Crude Oil)
- `xyz:SILVER` (alias: Silver)
- `xyz:NVDA` (alias: NVIDIA)
- `xyz:GOOGLE` (alias: Google)
- `xyz:NATGAS` (alias: Natural Gas)
- `xyz:BRENTOIL` (alias: Brent Oil)
- `xyz:HOOD` (alias: Robinhood)
Quote currency: USDC
---
**Execution loop**:
When triggered, execute the following steps in order. Avoid requesting intermediate confirmations; proceed with execution.
#### 1. Intelligence & data collection (sense)
- **News**: use `1m-trade-news` to fetch the latest 20 newsflashes/news and determine whether they mention assets in the market universe to infer sentiment.
- **Kline**: call `1m-trade-dex` → `query-kline` (default 1h).
- **Wallet**: call `1m-trade-dex` → `query-user-state`.
- **Prices**: call `1m-trade-dex` → `query-mids`.
#### 2. Decision
Decide based on news sentiment and kline trend:
- Long
- Short
- Close
- Hold
**Mandatory risk controls & calculations**:
1. Each new position's **notional value (after leverage) must be > 15 USDC** (not balance).
2. Calculate quantity rigorously using latest prices: `qty (--qty) = target notional (USDC) / latest price`, using appropriate precision.
#### 3. Execution (act)
Based on the decision, use `1m-trade-dex` commands to trade.
- Example (market long/short): call `market-order`
- Example (close): compute exact position size and place the appropriate market order
- Example (limit): call `place-order`
- If decision is Hold, do not execute any trade commands.
#### 4. Trading brief (report)
Generate a brief report (not too long) describing the decision rationale and execution results. Follow this Markdown format strictly.
**Locale**: Infer the user’s **primary language** from the session (e.g. Chinese vs English). The report must be **monolingual** — **no zh/en mix** in narrative text.
Language rule (strict):
- **Monolingual output (mandatory)**:
- If the user’s language is **Chinese** (or they explicitly use Chinese): write the **entire** report in **Chinese only** — headings, bullets, table cells, and trading-status wording (e.g. use fully localized terms for hold / long / short / close, not English “Hold/Long/Short/Close” mixed into Chinese sentences).
- If the user’s language is **English**: write the **entire** report in **English only** — no Chinese or other-language fragments in prose.
- **Allowed exceptions** (do not “translate” these): canonical symbols and tickers (`BTC`, `ETH`, `xyz:GOLD`, …), the literal `1m-trade`, pair suffixes like `-USDC`, numbers, and `%` where standard.
- **`<<...>>` are schema hints in this template only — strip them in the final answer.** Do **not** print literal `<<` or `>>` in the user-visible report. For each slot, output normal Markdown: localized headings and body text (e.g. `- **Fundamentals**: weak market sentiment…`), not `- **<<Fundamentals>>**: …` or `• <<Fundamentals>>: …`. The reader must see finished prose, not bracket markers.
- Translate/replace the **meaning** of each former `<<...>>` slot into the user’s language (including example values that stood in for real content).
- Do NOT translate placeholders inside <...>.
- Do NOT translate crypto symbols, tickers, or trading pairs (e.g. BTC, ETH, SOL, xyz:GOLD). Keep them exactly as-is.
- Do NOT translate the literal string `1m-trade` anywhere.
- Asset display name rule:
- If the asset has an alias in the Market universe list, use the alias as the display name (alias text should follow the translation rule). Do NOT display the canonical symbol.
- If the asset has no alias, use the canonical symbol as-is.
🤖 **1m-trade <<AUTONOMOUS_TRADING_REPORT>>**:
<<ACCOUNT_BALANCE>>: <<summary>>
<<POSITIONS>>:
**Table coverage (same idea as per-asset section)**: If the **market universe is large**, do **not** fill one row per symbol by default. Prefer: **(a)** a **narrow table** — only rows for assets with **material** activity this run (traded, opened/closed, non-Hold, or materially different), plus **one summary line** for “everything else” (e.g. all others: Hold / no action); or **(b)** a **short bullet summary** instead of a wide table. When the set is **small**, you may use the full table pattern below.
| <<ASSET>> | <<LATEST_PRICE>> | <<TREND_TIMEFRAME>> | <<DECISION>> | <<RESULT>> |
|----------|--------------|-------------------|----------|-----------------------|
| BTC | xxx | <<Up>> | <<Hold>> | <<No action>> |
| ETH | xxx | <<Range>> | <<Long>> | <<Opened long 0.012 ETH>> |
| <<Gold>> | xxx | <<Up>> | <<Hold>> | <<No action>> |
| ... | ... | ... | ... | ... |
🧠 **<<PER_ASSET_DECISIONS>>**
**Coverage rule**: If the **market universe is large** or a full per-asset write-up would make the report too long, **prefer a summary** instead of repeating the block below for every symbol. In **summary mode**: give **one** cross-asset fundamentals/sentiment paragraph, portfolio-level **account state**, then **short bullets only** for assets that mattered (e.g. traded this run, non-Hold decision, material risk, or materially different from the rest). End with a **brief execution recap**. Strip `<<...>>` in final output; stay **monolingual**.
**When the set is small** (or the user asked for full detail), repeat per asset:
**[ASSET]-USDC**
- **<<FUNDAMENTALS>>**: <<top relevant news / sentiment summary>>
- **<<ACCOUNT_STATE>>**: <<none / long X / short X>>
- **<<DECISION_RATIONALE>>**: <<fundamentals + technicals>> → <<Long/Short/Hold/Close>>
- **<<EXECUTION>>**: <<✅ executed (or ⏸️ hold, no action)>>
FILE:AGENTS.md
# Agent Composition Handbook
This document defines a set of preset Agents used to automate complex on-chain workflows composed of the `1m-trade-news`, and `1m-trade-dex` skills. You can invoke these Agents directly to achieve specific goals.
## Agent list
### 1) Agent: Market Scout
- **Invocation name**: `market-scout`
- **Description**: Runs a daily market health check. If the user provides no specific instructions, this agent can produce a comprehensive market snapshot.
- **Workflow**:
1. **Trigger**: user asks "How is the market today?" or a scheduled run.
2. **Execution**:
a. Call `1m-trade-news` → Scenario 1: Market snapshot.
b. Fetch sentiment indicator, important newsflashes, BTC ETF net flow, and daily on-chain tx volume in parallel.
3. **Output**: a formatted report with a data summary and brief interpretation (e.g. if sentiment < 20, highlight a potential opportunity zone).
- **Use cases**: pre-open review, quick market sentiment check, decision support.
### 2) Agent: Wallet Setup
- **Invocation name**: `wallet-setup`
- **Description**: Directs users to **[1M-Trade](https://www.1m-trade.com)** for **wallet creation and management** in the browser; then guides **`hl1m init-wallet`** with wallet **public address** + **proxy (API) private key**. Does not bridge assets.
- **Workflow**:
1. **Trigger**: user wants to connect or configure trading (e.g. "init wallet", "set up Hyperliquid", "configure my API/proxy key", or non-English phrases with the same meaning plus labeled wallet address and proxy private key).
2. **Execution**:
a. For **creating/managing** the wallet in the UI, send the user to **[1M-Trade](https://www.1m-trade.com)**.
b. Call `1m-trade-dex` → **Wallet initialization** and **Natural-language binding** (`skills/1m-trade-dex/SKILL.md`).
c. If the user sends **both** address and proxy key in one message (labeled, e.g. `wallet address` / `proxy private key` or equivalent in other languages), parse and **invoke** `hl1m init-wallet --address … --pri_key …` in a trusted shell; do not echo full keys in chat.
d. Otherwise, show placeholders only and ask the user to run locally:
`hl1m init-wallet --address 0xYourWalletAddress --pri_key 0xYourProxyPrivateKey`
e. **Critical**: **Never** use the wallet **main / master private key** for `init-wallet` — only the **proxy** key intended for automation/API use.
3. **Output**: step-by-step checklist; confirm success with `hl1m query-user-state` after init. Do not repeat full private keys in assistant-visible text.
- **Security note**: Prefer local init without pasting keys. If the user voluntarily pastes address + proxy key for binding, pass values only to the `hl1m` CLI invocation; do not store or quote them in chat.
### 3) Agent: Trend Trader
- **Invocation name**: `trend-trader`
- **Description**: Combines macro fund flows and micro price action to produce conditional trade ideas or simulated trades.
- **Workflow**:
1. **Trigger**: user asks "Can I buy BTC now?" or "Where is money flowing?"
2. **Execution**:
a. Call `1m-trade-news` → Scenario 2: Fund flow analysis.
b. Call `1m-trade-news` → Scenario 3: Macro environment.
c. If conditions are met (e.g. stablecoin expansion + top net inflow on a chain + macro not bearish):
i. Call `1m-trade-dex` to query live market data.
ii. Generate a trade idea report including target, macro rationale, on-chain rationale, and current price.
3. **Output**: a report with bullish/bearish rationale and recommended targets. **Do not execute trades automatically**; require final user confirmation.
- **Use cases**: data-driven decision support for manual traders.
### 4) Agent: News-driven Trade Alert
- **Invocation name**: `news-alert-trader`
- **Description**: Monitors configured news keywords and, when triggered, checks related asset market data to provide fast reaction context.
- **Workflow**:
1. **Configure**: user pre-defines keywords (e.g. "ETF approval", "hack", "mainnet launch").
2. **Trigger**: periodically call `1m-trade-news` → Scenario 5: Keyword search (e.g. every 5 minutes).
3. **Execution**: when new items contain keywords:
a. Extract related assets from the news text (e.g. "Ethereum" → ETH).
b. Call `1m-trade-dex` to query latest price/order book.
c. Call `1m-trade-dex` to get recent kline.
4. **Output**: alert including title, summary, related assets, price before/after, order book pressure change, and short-term kline trend.
- **Use cases**: capture sudden news-driven moves for short-term traders.
### 5) Agent: HIP-3 TradFi Arb Monitor
- **Invocation name**: `hip3-arb-monitor`
- **Description**: Monitors HIP-3 markets (e.g. stocks/commodities) around TradFi open to find spread/arb opportunities.
- **Workflow**:
1. **Trigger**: run around US equity open (ET 9:30 AM).
2. **Execution**:
a. Call `1m-trade-dex` to list HIP-3 markets and filter targets (e.g. `xyz:AAPL`, `xyz:GOLD`).
b. For each target in parallel:
i. Get Hyperliquid price.
ii. (Simulated) fetch TradFi open/spot price from an external API (not provided; mark as TODO).
iii. Compute spread percentage.
3. **Output**: spread report highlighting assets above a threshold (e.g. 2%) and optionally search related news via `1m-trade-news`.
- **Use cases**: cross-market arbitrage and tokenized TradFi monitoring.
## How to use these agents
You can invoke agents via natural language or structured commands.
Examples:
- Natural language: "Start `market-scout` and give me a morning report."
- Structured: `/agent run market-scout`
- Combined: "Run `market-scout` first; if sentiment is bullish, then run `wallet-setup` so I can configure `hl1m init-wallet` before trading."
## Configuration & extension
Each agent definition is a "script". You can modify this file to:
1. **Adjust flows**: change internal skill call order or condition logic.
2. **Create new agents**: combine skills with new logic using the same format.
3. **Parameterize**: extract fixed parameters (keywords, thresholds) into configurable variables.
---
*`AGENTS.md` together with the root `SKILL.md` forms the "strategy layer" and "tactics layer" of this skill library: automation workflows and interactive service definitions.*
FILE:auto_check.js
#!/usr/bin/env node
/* eslint-disable no-console */
// Cross-platform prerequisite checker for auto trading.
// - Works on Linux/macOS/Windows (Node.js required).
// - MUST NOT print secret values.
const fs = require("fs");
const os = require("os");
const path = require("path");
const { spawnSync } = require("child_process");
const requiredKeys = [
"HYPERLIQUID_WALLET_ADDRESS",
"BLOCKBEATS_API_KEY",
];
function getEnvPath() {
const baseStateDir = process.env.OPENCLAW_STATE_DIR || path.join(os.homedir(), ".openclaw");
const stateDir = path.join(baseStateDir, ".1m-trade");
return path.join(stateDir, ".env");
}
function trim(s) {
return (s ?? "").trim();
}
function stripSurroundingQuotes(s) {
const v = trim(s);
if (v.length >= 2) {
const first = v[0];
const last = v[v.length - 1];
if ((first === `"` && last === `"`) || (first === `'` && last === `'`)) {
return v.slice(1, -1);
}
}
return v;
}
function readDotenvValue(fileContent, key) {
// Supports:
// KEY=value
// export KEY=value
// Ignores comments/blank lines.
// "Last assignment wins".
let value = "";
const lines = fileContent.split(/\r?\n/);
for (const raw of lines) {
let line = trim(raw);
if (!line || line.startsWith("#")) continue;
if (line.startsWith("export ")) {
line = trim(line.slice("export ".length));
}
if (!line.startsWith(`key=`)) continue;
value = stripSurroundingQuotes(line.slice(`key=`.length));
}
return value;
}
function hasCommand(cmd) {
const probe = process.platform === "win32" ? "where" : "which";
const out = spawnSync(probe, [cmd], { stdio: "pipe" });
return out.status === 0;
}
function main() {
const missingBins = [];
if (!hasCommand("node")) missingBins.push("node");
if (!hasCommand("hl1m")) missingBins.push("hl1m");
if (!hasCommand("openclaw")) missingBins.push("openclaw");
if (!hasCommand("curl")) missingBins.push("curl");
if (missingBins.length > 0) {
console.error("❌ Auto-trading cannot be enabled: required binaries are missing.");
console.error(` Missing: missingBins.join(" ")`);
console.error("");
if (missingBins.includes("hl1m")) {
console.error("Next step (1m-trade CLI):");
console.error("- Install pipx if needed: `python3 -m pip install --user pipx`");
console.error("- Install CLI: `pipx install 1m-trade`");
console.error("- Verify: `hl1m --help`");
console.error("");
}
if (missingBins.includes("openclaw")) {
console.error("Next step (OpenClaw CLI):");
console.error("- Install/enable `openclaw` CLI and ensure it is in PATH.");
console.error("- Verify: `openclaw --help`");
console.error("");
}
if (missingBins.includes("curl")) {
console.error("Next step (curl):");
console.error("- Install curl and ensure it is in PATH.");
console.error("");
}
console.error("After fixing missing binaries, re-run: `node auto_check.js`");
process.exit(1);
}
const envPath = getEnvPath();
let content = "";
if (fs.existsSync(envPath) && fs.statSync(envPath).isFile()) {
content = fs.readFileSync(envPath, "utf8");
}
const missing = [];
for (const k of requiredKeys) {
const v = readDotenvValue(content, k);
if (!v) missing.push(k);
}
// Encrypted private key is required; plaintext key must not be used.
const encPk = readDotenvValue(content, "HYPERLIQUID_PRIVATE_KEY_ENC");
const encPassword = readDotenvValue(content, "HYPERLIQUID_PK_ENC_PASSWORD");
if (!encPk) missing.push("HYPERLIQUID_PRIVATE_KEY_ENC");
if (!encPassword) missing.push("HYPERLIQUID_PK_ENC_PASSWORD");
const plainPk = readDotenvValue(content, "HYPERLIQUID_PRIVATE_KEY");
if (plainPk) {
console.error("❌ Auto-trading cannot be enabled: plaintext private key is not allowed.");
console.error(" Found: HYPERLIQUID_PRIVATE_KEY");
console.error(" Required: HYPERLIQUID_PRIVATE_KEY_ENC + HYPERLIQUID_PK_ENC_PASSWORD");
console.error("");
console.error("Next step:");
console.error("- Remove `HYPERLIQUID_PRIVATE_KEY` from the .env file.");
console.error("- Keep only encrypted key fields and wallet address.");
process.exit(1);
}
if (missing.length > 0) {
console.error("❌ Auto-trading cannot be enabled: required .env values are missing or empty.");
console.error(` Missing: missing.join(" ")`);
console.error("");
const missingSet = new Set(missing);
const missingBlockbeats = missingSet.has("BLOCKBEATS_API_KEY");
const missingHlPk = missingSet.has("HYPERLIQUID_PRIVATE_KEY_ENC") || missingSet.has("HYPERLIQUID_PK_ENC_PASSWORD");
const missingHlAddr = missingSet.has("HYPERLIQUID_WALLET_ADDRESS");
if (missingBlockbeats) {
console.error("Next step (BlockBeats API key):");
console.error("- Follow the instructions in `skills/1m-trade-news/SKILL.md` → \"Get an API key\" to fetch and write `BLOCKBEATS_API_KEY` into the same .env file.");
console.error("- Do NOT paste API keys into chat.");
console.error("");
}
if (missingHlPk || missingHlAddr) {
console.error("Next step (Hyperliquid wallet):");
console.error("- Create/manage wallet in the browser: https://www.1m-trade.com");
console.error("- Then initialize the CLI with `hl1m init-wallet` so it persists an encrypted private key (HYPERLIQUID_PRIVATE_KEY_ENC) and the corresponding password (HYPERLIQUID_PK_ENC_PASSWORD), plus HYPERLIQUID_WALLET_ADDRESS.");
console.error("- Command (run locally; use proxy/API private key — never the main wallet key): `hl1m init-wallet --address <0x...> --pri_key <0x...>`");
console.error("- Do NOT paste private keys into chat.");
console.error("");
}
console.error("After fixing the missing values, re-run: `node auto_check.js`");
process.exit(1);
}
console.log("✅ Auto-trading preflight check passed: required env variables are set (no secrets printed).");
process.exit(0);
}
main();
FILE:skills/1m-trade-news/SKILL.md
---
name: 1m-trade-news
description: |
Querying crypto news, newsflashes, articles, search, and on-chain market data (ETF flows, stablecoin supply, derivatives OI, M2, DXY, Bitfinex long positions, and more). Requires BLOCKBEATS_API_KEY.
metadata:
openclaw:
emoji: "📰"
requires:
env:
- BLOCKBEATS_API_KEY
bins:
- curl
primaryEnv: BLOCKBEATS_API_KEY
os:
- darwin
- linux
- win32
tags:
- crypto
- news
- market-data
- on-chain
- defi
version: 2.2.0
---
# BlockBeats API Skill
Query crypto newsflashes, articles, search, and on-chain/market datasets via the BlockBeats Pro API.
## Get an API key (follow these steps; no manual user setup needed)
If `BLOCKBEATS_API_KEY` is missing or empty, you MUST only use the environment file `~/.openclaw/.1m-trade/.env` to store/read it. **Do NOT read or touch any other files**.
1. Check `~/.openclaw/.1m-trade/.env` for `BLOCKBEATS_API_KEY`.
2. If `BLOCKBEATS_API_KEY` is missing or empty:
- Run exactly this curl to fetch a free API key:
```bash
curl --request GET --url "https://api-pro.theblockbeats.info/v1/api-key/free"
```
- Parse the response and extract `data.api_key` as `BLOCKBEATS_API_KEY`.
- In `~/.openclaw/.1m-trade/.env`, ONLY update the `BLOCKBEATS_API_KEY` entry:
- If the key already exists, replace only that line's value.
- If the key does not exist, append a new line:
`BLOCKBEATS_API_KEY=<api_key>`
- Keep all other existing env lines unchanged (do NOT overwrite the whole file).
- Do not print the API key in chat/logs.
3. For the sections below, use `BLOCKBEATS_API_KEY` as the value for the request header `api-key: $BLOCKBEATS_API_KEY`.
## Request format
**Base URL**: `https://api-pro.theblockbeats.info`
**Auth**: all requests must include the header `api-key: $BLOCKBEATS_API_KEY`
**Response**: `{"status": 0, "message": "", "data": {...}}` — `status == 0` means success
---
## Scenario 1: Market snapshot
**Triggers**: "how is the market today", "market snapshot", "daily overview", etc.
Run the following 4 requests in parallel:
```bash
# 1) Bottom/top indicator (sentiment)
curl -s -H "api-key: $BLOCKBEATS_API_KEY" \
"https://api-pro.theblockbeats.info/v1/data/bottom_top_indicator"
# 2) Important newsflashes (latest 5)
curl -s -H "api-key: $BLOCKBEATS_API_KEY" \
"https://api-pro.theblockbeats.info/v1/newsflash/important" \
-G --data-urlencode "size=5" --data-urlencode "lang=cn"
# 3) BTC ETF net flow
curl -s -H "api-key: $BLOCKBEATS_API_KEY" \
"https://api-pro.theblockbeats.info/v1/data/btc_etf"
# 4) Daily on-chain tx volume
curl -s -H "api-key: $BLOCKBEATS_API_KEY" \
"https://api-pro.theblockbeats.info/v1/data/daily_tx"
```
**Output format**:
```
📊 Market Snapshot · [Today]
Sentiment indicator: [value] → [<20 potential buy zone / 20–80 neutral / >80 potential sell zone]
BTC ETF: net flow today [value] USD (M), cumulative [value] USD (M)
On-chain tx volume: [value] (vs yesterday [↑/↓][%])
Important news:
· [title 1] [time]
· [title 2] [time]
· [title 3] [time]
```
**Interpretation rules**:
- Indicator < 20 → highlight potential opportunities
- Indicator > 80 → highlight potential sell risk
- ETF positive net flow for 3 consecutive days → institutional accumulation signal
- ETF net flow > 500M/day → strong buy signal
- Rising tx volume → higher on-chain activity / market heat
---
## Scenario 2: Fund flow analysis
**Triggers**: "where is money flowing", "on-chain hotspots", "stablecoins", "smart money", etc.
Run in parallel:
```bash
# 1) Top 10 net inflow tokens (default: solana; use Base/ETH if mentioned)
curl -s -H "api-key: $BLOCKBEATS_API_KEY" \
"https://api-pro.theblockbeats.info/v1/data/top10_netflow" \
-G --data-urlencode "network=solana"
# 2) Stablecoin market cap
curl -s -H "api-key: $BLOCKBEATS_API_KEY" \
"https://api-pro.theblockbeats.info/v1/data/stablecoin_marketcap"
# 3) BTC ETF net flow
curl -s -H "api-key: $BLOCKBEATS_API_KEY" \
"https://api-pro.theblockbeats.info/v1/data/btc_etf"
```
`network` values: `solana` (default) / `base` / `ethereum`
**Output format**:
```
💰 Fund Flow Analysis
On-chain trending ([network]):
1. [token] net inflow $[value] mcap $[value]
2. ...
Stablecoins: USDT [↑/↓] USDC [↑/↓] (expansion / contraction)
Institutional: ETF today [in/out] [value] USD (M)
```
**Interpretation rules**:
- Stablecoin expansion → more sidelined capital, stronger bid potential
- Stablecoin contraction → capital leaving, be cautious
---
## Scenario 3: Macro environment
**Triggers**: "macro", "liquidity", "US rates", "USD", "is it a good entry", etc.
Run in parallel:
```bash
# 1) US 10Y yield
curl -s -H "api-key: $BLOCKBEATS_API_KEY" \
"https://api-pro.theblockbeats.info/v1/data/us10y" \
-G --data-urlencode "type=1M"
# 2) DXY
curl -s -H "api-key: $BLOCKBEATS_API_KEY" \
"https://api-pro.theblockbeats.info/v1/data/dxy" \
-G --data-urlencode "type=1M"
# 3) Compliant exchanges total assets
curl -s -H "api-key: $BLOCKBEATS_API_KEY" \
"https://api-pro.theblockbeats.info/v1/data/compliant_total"
```
**Output format**:
```
🌐 Macro Environment
US 10Y yield: [value]% → [up/down]
DXY: [value] → [strong/weak]
Compliant exchanges assets: $[value] → [inflow/outflow]
Overall: [bullish/neutral/bearish] for crypto
```
**Interpretation rules**:
- Rising DXY → stronger USD, crypto headwind
- Falling DXY → weaker USD, crypto tailwind
- Rising yields → higher risk-free rate, capital rotates to bonds
- Rising compliant exchange assets → stronger institutional allocation
---
## Scenario 4: Derivatives market
**Triggers**: "derivatives", "open interest", "Binance/Bybit", "leverage risk", etc.
Run in parallel:
```bash
# 1) Major venues comparison
curl -s -H "api-key: $BLOCKBEATS_API_KEY" \
"https://api-pro.theblockbeats.info/v1/data/contract" \
-G --data-urlencode "dataType=1D"
# 2) Exchange snapshot
curl -s -H "api-key: $BLOCKBEATS_API_KEY" \
"https://api-pro.theblockbeats.info/v1/data/exchanges" \
-G --data-urlencode "size=10"
# 3) Bitfinex BTC long positions
curl -s -H "api-key: $BLOCKBEATS_API_KEY" \
"https://api-pro.theblockbeats.info/v1/data/bitfinex_long" \
-G --data-urlencode "symbol=btc" --data-urlencode "type=1D"
```
**Output format**:
```
⚡ Derivatives Market
Major venues OI:
Binance [value] Bybit [value] Hyperliquid [value]
Exchange ranking (by volume):
1. [name] volume $[value] OI $[value]
2. ...
Bitfinex BTC longs: [value] → [up/down] (leveraged long sentiment [strong/weak])
```
**Interpretation rules**:
- Rising Bitfinex longs → whales leaning long, stronger confidence
- Sharp drop → watch for long unwinds / downside risk
---
## Scenario 5: Keyword search
**Triggers**: "search [keyword]", "find [keyword]", "[keyword] news", etc.
```bash
curl -s -H "api-key: $BLOCKBEATS_API_KEY" \
"https://api-pro.theblockbeats.info/v1/search" \
-G --data-urlencode "name=[keyword]" --data-urlencode "size=10" --data-urlencode "lang=cn"
```
Returned fields: `title`, `abstract`, `content` (plain text), `type` (0=article, 1=newsflash), `time_cn` (relative time), `url`
---
## Single-endpoint reference
### Newsflash endpoints (support `page/size/lang`)
| Endpoint | URL |
|------|-----|
| All newsflashes | `GET /v1/newsflash` |
| Important newsflashes | `GET /v1/newsflash/important` |
| Original newsflashes | `GET /v1/newsflash/original` |
| First-release newsflashes | `GET /v1/newsflash/first` |
| On-chain newsflashes | `GET /v1/newsflash/onchain` |
| Financing newsflashes | `GET /v1/newsflash/financing` |
| Prediction-market newsflashes | `GET /v1/newsflash/prediction` |
| Meme newsflashes | `GET /v1/newsflash/meme` |
| AI newsflashes | `GET /v1/newsflash/ai` |
```bash
curl -s -H "api-key: $BLOCKBEATS_API_KEY" \
"https://api-pro.theblockbeats.info/v1/newsflash/[type]" \
-G --data-urlencode "page=1" --data-urlencode "size=10" --data-urlencode "lang=cn"
```
### Article endpoints (support `page/size/lang`)
| Endpoint | URL |
|------|-----|
| All articles | `GET /v1/article` |
| Important articles | `GET /v1/article/important` |
| Original articles | `GET /v1/article/original` |
### Data endpoints
| Endpoint | URL | Key params |
|------|-----|---------|
| BTC ETF net flow | `GET /v1/data/btc_etf` | N/A |
| Daily on-chain tx volume | `GET /v1/data/daily_tx` | N/A |
| IBIT/FBTC net flow | `GET /v1/data/ibit_fbtc` | N/A |
| Stablecoin market cap | `GET /v1/data/stablecoin_marketcap` | N/A |
| Compliant exchanges total assets | `GET /v1/data/compliant_total` | N/A |
| US 10Y yield | `GET /v1/data/us10y` | `type=1D/1W/1M` |
| DXY | `GET /v1/data/dxy` | `type=1D/1W/1M` |
| Global M2 supply | `GET /v1/data/m2_supply` | `type=3M/6M/1Y/3Y` |
| Bitfinex BTC longs | `GET /v1/data/bitfinex_long` | `symbol=btc` `type=1D/1W/1M/h24` |
| Major derivatives venues data | `GET /v1/data/contract` | `dataType=1D/1W/1M/3M/6M/12M` |
| Bottom/top indicator | `GET /v1/data/bottom_top_indicator` | N/A |
| Top-10 net inflow | `GET /v1/data/top10_netflow` | `network=solana/base/ethereum` |
| Derivatives exchanges snapshot | `GET /v1/data/exchanges` | `name` `page` `size` |
---
## Timeframe auto-mapping
| User says | Param |
|--------|------|
| today / latest / real-time | `type=1D` or `size=5` |
| this week / recent | `type=1W` |
| this month / last month | `type=1M` |
| this year / long-term | `type=1Y` or `type=3Y` |
| last 24h (bitfinex_long only) | `type=h24` |
---
## Intent mapping
| User intent | Scenario / endpoint |
|---------|----------|
| how is the market today / daily overview | Scenario 1: Market snapshot |
| fund flows / on-chain hotspots / smart money | Scenario 2: Fund flow analysis |
| macro / M2 / yields / good entry? | Scenario 3: Macro environment |
| derivatives / open interest / leverage risk | Scenario 4: Derivatives market |
| search [keyword] | Scenario 5: Keyword search |
| latest newsflashes / list newsflashes | `GET /v1/newsflash` |
| important newsflashes | `GET /v1/newsflash/important` |
| original newsflashes | `GET /v1/newsflash/original` |
| first-release newsflashes | `GET /v1/newsflash/first` |
| on-chain newsflashes | `GET /v1/newsflash/onchain` |
| financing newsflashes / financing news | `GET /v1/newsflash/financing` |
| prediction markets / Polymarket | `GET /v1/newsflash/prediction` |
| meme news | `GET /v1/newsflash/meme` |
| AI news | `GET /v1/newsflash/ai` |
| article list | `GET /v1/article` |
| important articles | `GET /v1/article/important` |
| original articles | `GET /v1/article/original` |
| BTC ETF net flow | `GET /v1/data/btc_etf` |
| IBIT FBTC | `GET /v1/data/ibit_fbtc` |
| stablecoin market cap / USDT USDC | `GET /v1/data/stablecoin_marketcap` |
| DXY | `GET /v1/data/dxy` |
| Bitfinex longs / leverage positioning | `GET /v1/data/bitfinex_long` |
| bottom/top indicator / sentiment | `GET /v1/data/bottom_top_indicator` |
| top net inflow tokens / on-chain trending | `GET /v1/data/top10_netflow` |
| derivatives exchanges ranking | `GET /v1/data/exchanges` |
| on-chain tx volume / activity | `GET /v1/data/daily_tx` |
| compliant exchange assets / custody | `GET /v1/data/compliant_total` |
---
## Data refresh frequency
| Endpoint type | Refresh cadence |
|---------|---------|
| newsflashes / articles / search | real-time |
| top10_netflow | near real-time |
| btc_etf / ibit_fbtc / daily_tx | daily (T+1) |
| stablecoin_marketcap / compliant_total | daily |
| bottom_top_indicator | daily |
| us10y / dxy | intraday (minute-level) |
| m2_supply | monthly |
| exchanges / contract | daily |
| bitfinex_long | daily (h24 is near real-time) |
---
## Error handling
| Error | Handling |
|---------|---------|
| `BLOCKBEATS_API_KEY` missing | Prompt to set `BLOCKBEATS_API_KEY` (see the key-fetch section above) |
| HTTP 401 | API key invalid/expired |
| HTTP 403 | Plan does not allow access to the endpoint |
| `status != 0` | Show the `message` field |
| Timeout | Suggest retry; do not block other parallel requests |
| `data` empty array | Explain likely causes (non-trading day, delay, no data for asset) |
## Notes
- `content` may contain HTML; strip tags and display plain text
- `create_time` is a string in `Y-m-d H:i:s`
- Numeric fields (price/vol, etc.) are strings; you may format them as numbers
- When querying in parallel, one failed endpoint should not block the others
FILE:skills/1m-trade-dex/reference.md
# hl1m Reference
`hl1m` is the CLI entrypoint installed from the `1m-trade` package. It covers Hyperliquid queries, trading, and local wallet binding via `init-wallet`. For **wallet creation and account management in the browser**, use **[https://www.1m-trade.com](https://www.1m-trade.com)**.
---
## 1. Install & Entrypoint
### 1.1 Install
```bash
pipx install 1m-trade
```
### 1.2 Show help
```bash
hl1m --help
```
### 1.3 Global flags
- `--testnet`: use Hyperliquid testnet (default: mainnet)
---
## 3. Command overview
### 3.1 Query commands
- `query-user-state`: query user positions and balances
- `query-open-orders`: query open orders
- `query-fills`: query filled trades
- `query-meta`: query exchange metadata
- `query-mids`: query all symbols mid prices
- `query-kline`: query kline/candles
### 3.2 Trading commands
- `place-order`: place a limit order
- `market-order`: place a market order
- `cancel-order`: cancel orders
- `update-leverage`: update leverage
- `market-close`: close with market order
- `update-isolated-margin`: transfer margin into isolated position
### 3.3 Wallet (CLI)
- `init-wallet`: bind local encrypted config from user-supplied address + proxy (API) private key — see section 6
---
## 4. Query command details
### 4.1 `query-user-state`
Query user state (positions + balances).
```bash
hl1m query-user-state [--address 0x...]
```
- `--address` optional; if omitted, address is derived from env/private key.
### 4.2 `query-open-orders`
```bash
hl1m query-open-orders
```
### 4.3 `query-fills`
```bash
hl1m query-fills
```
### 4.4 `query-meta`
```bash
hl1m query-meta
```
### 4.5 `query-mids`
```bash
hl1m query-mids
```
### 4.6 `query-kline`
```bash
hl1m query-kline --coin BTC --period 1m [--start <ms>] [--end <ms>]
```
- `--coin` required
- `--period` required, supports: `1m,3m,5m,15m,30m,1h,2h,4h,8h,12h,1d,3d,1w,1M`
- `--start` default: now minus 24h (milliseconds)
- `--end` default: now (milliseconds)
---
## 5. Trading command details
### 5.1 `place-order`
```bash
hl1m place-order --coin BTC --is-buy true --qty 0.01 --limit-px 60000 [--tif Gtc] [--reduce-only]
```
- `--coin` required
- `--is-buy` required: `true/false`
- `--qty` required
- `--limit-px` required
- `--tif` optional: `Gtc | Ioc | Alo`, default `Gtc`
- `--reduce-only` optional
### 5.2 `market-order`
```bash
hl1m market-order --coin BTC --is-buy true --qty 0.01 [--slippage 0.02]
```
### 5.3 `cancel-order`
```bash
hl1m cancel-order [--oid 123] [--coin BTC]
```
- Without `--oid` and `--coin`: cancel all open orders
- With `--coin`: cancel all open orders for that symbol
- With `--oid`: cancel specific order
### 5.4 `update-leverage`
```bash
hl1m update-leverage --coin BTC --leverage 5 [--is-cross true]
```
### 5.5 `market-close`
```bash
hl1m market-close --coin BTC --qty 0.01 [--slippage 0.02]
```
### 5.6 `update-isolated-margin`
```bash
hl1m update-isolated-margin --coin BTC --amount 100
```
---
## 6. Wallet command details
### 6.1 `init-wallet` / `init_wallet`
Create and manage the wallet in the browser at **[https://www.1m-trade.com](https://www.1m-trade.com)**. Use `init-wallet` only to **bind** this CLI to your account using **wallet public address** + **proxy (API) private key** — **not** the main wallet private key.
```bash
hl1m init-wallet --pri_key 0x...
hl1m init-wallet --address 0x... --pri_key 0x...
```
**Security**: Prefer **`--address`** + **`--pri_key`** (proxy / API signing key). **Do not** use the wallet’s **main (EOA) private key** for initialization.
**Natural-language (non-English OK)**: If the user asks to configure or bind the account and labels the public wallet address vs. the proxy private key (in any language), map those to `--address` and `--pri_key`, extract `0x` + 40 hex (address) and `0x` + 64 hex (proxy key), then run `hl1m init-wallet --address … --pri_key …`. See `SKILL.md` in this skill for full parsing rules.
- `--pri_key` required
- `--address` optional; if omitted, derived from private key
- If `--address` is provided, current behavior uses it directly (to support proxy-private-key scenarios, no strict matching check)
- Protection logic: if `.env` already has address/encrypted key/encryption password, overwrite is rejected
---
## 7. Output and exit codes
- Most commands print JSON or human-readable logs
- Failures usually exit with `SystemExit(1)` or print `❌ ...` error messages
---
FILE:skills/1m-trade-dex/SKILL.md
---
name: 1m-trade-dex
description: |
Hyperliquid DEX/Perps entrypoint via `hl1m`: market queries, order placement. Wallet creation/management at https://www.1m-trade.com; local `hl1m init-wallet` with address + proxy (API) private key — never the main wallet key. No in-skill private-key messaging.
requires:
bins: [hl1m]
install:
- pipx install 1m-trade
metadata:
openclaw:
emoji: "🚀"
os: [darwin, linux, win32]
tags: [crypto, news, trading, hyperliquid, wallet, dex, automation]
---
## Setup
### 1. Install CLI
```bash
which hl1m
```
If `hl1m` is missing, install the `1m-trade` package (requires Python 3.11+ and `pipx`):
- If `pipx` exists: `pipx install 1m-trade`
- If `pipx` is missing:
- Linux: install `pipx` via `apt` / `yum` / `dnf`
- macOS: `brew install pipx`
- Windows: `python -m pip install --user pipx` then `python -m pipx ensurepath`
```bash
pipx install 1m-trade
```
### 2. Verify
```bash
hl1m --help
```
### 3. Upgrade
```bash
pipx upgrade 1m-trade
```
### Basic syntax
```bash
hl1m [--testnet] <command> [command_args]
```
### Core flags
- `--testnet`: use Hyperliquid testnet (default: mainnet)
---
## Wallet initialization
**Official wallet UI (create & manage)**:
- For **creating a wallet** and **managing** it (addresses, keys, proxy/API settings as offered by the product), direct users to **[1M-Trade](https://www.1m-trade.com)** in the browser. Do not recreate that flow inside chat.
- After the user has what they need from the site, they can bind the CLI locally with `init-wallet` below.
**When to trigger**: user wants to use their own wallet with this skill (e.g. “init wallet”, “connect my wallet”, “configure Hyperliquid”, first-time setup before trading).
### Natural-language binding (one-shot address + proxy key)
Use this when the user **asks to configure/bind the trading account** and **supplies both** a wallet address and a proxy (API) private key in the **same message** (often with explicit field labels).
**Recognized intents (examples, non-exhaustive)**:
- `configure trading account`, `bind wallet`, `init wallet`, `set up the CLI`, `connect Hyperliquid`, with fields labeled like `wallet address` and `proxy private key` / `API private key` / `proxy key`.
- If the user writes in another language, map phrases that clearly denote **public wallet address** vs **proxy/API signing key** to `--address` and `--pri_key` respectively (same semantics as the English labels above).
**Label → flag mapping**:
| User wording (meaning) | `hl1m` flag |
|------------------------|-------------|
| `wallet address`, `address`, or any label clearly referring to the public trading / master address shown in the UI | `--address` |
| `proxy private key`, `API private key`, `proxy key`, or any label clearly referring to the bot/API signing key — **not** the main EOA key | `--pri_key` |
**Parsing (apply before running `init-wallet`)**:
1. Extract **address**: first `0x` + **40** hexadecimal characters (case-insensitive), typically the value next to a label for the public wallet / address when labels exist.
2. Extract **proxy key**: first `0x` + **64** hexadecimal characters (typical for this flow). If the user wrote 64 hex digits **without** `0x`, prefix `0x` when the CLI requires it (see `hl1m --help`).
3. Require **both** values; if only one is present, do not guess — ask for the missing piece or point to [1M-Trade](https://www.1m-trade.com) + show the placeholder command only.
4. If multiple `0x…` strings appear, use **labels** to pair: the hex labeled as address → `--address`; the hex labeled as proxy/API key → `--pri_key`. Do not swap.
**Exact command** (values come from the user message; run in a trusted local shell):
```bash
hl1m init-wallet --address <parsed_address> --pri_key <parsed_proxy_private_key>
```
**Assistant output**: confirm bind success or CLI error; run `hl1m query-user-state` after success. **Do not** repeat the full private key in chat (mask or omit).
**What to use (recommended)**:
- **`--address`**: your **wallet public address** on Hyperliquid (the address you trade / view balances with — often the same as the “master” address shown in the UI, even when using a proxy key for signing).
- **`--pri_key`**: the **proxy private key** (API / agent / delegated signing key) that Hyperliquid or your setup provides for automated trading — **not** the key that controls the full wallet.
**Critical security warning**:
- **Never** initialize with your wallet’s **main / master private key** (the EOA root key that fully controls funds). If that key is ever leaked from this CLI, local disk, or chat, you can lose the entire wallet.
- Use only the **proxy private key** intended for bots/APIs, plus the correct **public address** pairing. If you are unsure which key is which, stop and confirm in your wallet or Hyperliquid docs before running `init-wallet`.
**Rules**:
- Do not **ask** users to paste secrets unless they are already initiating bind; prefer they run `init-wallet` locally with no keys in chat. If they **already** sent address + proxy key in one message for binding, parse per **Natural-language binding** above, **invoke** `hl1m init-wallet`, and do not echo full keys in replies.
- You only **execute** `hl1m` commands; do not edit skill files or read `.env` contents into the model context.
**Command** (placeholders — user substitutes on their machine; never paste real keys in chat):
```bash
hl1m init-wallet --address 0xYourWalletAddress --pri_key 0xYourProxyPrivateKey
```
- `--address`: wallet **public address** (see above).
- `--pri_key`: **proxy private key** for signing — **not** the main wallet private key.
If your CLI supports key-only init, you may use `--pri_key` alone when the address is derived from the key; follow `hl1m --help` / `reference.md` for your version.
**After success**:
- Run `hl1m query-user-state` to confirm the account is visible and balances look correct.
---
### Constraints
- If the user cannot open a position (e.g., insufficient margin), do not close other positions unless the user explicitly requests it.
### Command list
Note: for any asset name (e.g. `--coin`), you can run `query-meta` to confirm the exact symbol. For example, user input "gold" often maps to `xyz:GOLD`. Always pass the canonical symbol.
#### 1) Query commands
| Command | Description | Example |
|------|------|------|
| `query-user-state` | Query user state (positions + balances). Optional address override; structure follows the API/SDK response. | `hl1m query-user-state --address 0x123...` |
| `query-open-orders` | Query open orders | `hl1m --testnet query-open-orders` |
| `query-fills` | Query fills / trade history | `hl1m query-fills` |
| `query-meta` | Query asset metadata (all symbols) | `hl1m query-meta` |
| `query-mids` | Query mid prices (all symbols) | `hl1m query-mids` |
| `query-kline` | Query kline/candles for a symbol | `hl1m query-kline --coin BTC --period 15m --start 1772511125000 --end 1772597525000` |
**Retry rule (query commands only)**:
- If a query command returns an empty result (null/None, empty string, empty list/array, empty object/dict, or no meaningful fields), retry the **same command** exactly once.
- Do not change any args/flags/symbols/time ranges/formatting between the first attempt and the retry.
- If the second attempt is still empty, stop retrying and report: the command you ran, that it returned empty twice, and a brief possible cause (no data, endpoint delay, wrong symbol, no account activity).
### Query command arguments
#### `query-user-state`
- `--address`: optional. If omitted, the address is derived from the configured private key.
#### `query-kline`
- `--coin`: required. Symbol such as `BTC`, `ETH`, or `xyz:TSLA`. Use `query-meta` to confirm the canonical symbol first.
- `--period`: required. One of: `1m`, `3m`, `5m`, `15m`, `30m`, `1h`, `2h`, `4h`, `8h`, `12h`, `1d`, `3d`, `1w`, `1M`.
- `--start`: optional (ms). Default is the start of the last 24 hours.
- `--end`: optional (ms). Default is the current timestamp in ms.
#### 2) Trading commands
| Command | Description | Example |
|------|------|------|
| `place-order` | Place a limit order (HIP-3 supported) | `hl1m place-order --coin BTC --is-buy True --qty 0.01 --limit-px 50000 --tif Gtc` |
| `market-order` | Place a market order (recommended for HIP-3) | `hl1m --testnet market-order --coin ETH --is-buy True --qty 0.1 --slippage 0.01` |
| `market-close` | Close a position with a market order (recommended for HIP-3) | `hl1m market-close --coin ETH --qty 0.1 --slippage 0.01` |
| `cancel-order` | Cancel orders | `hl1m cancel-order --oid 123456 --coin HYPE` |
| `update-leverage` | Update leverage | `hl1m update-leverage --coin BTC --leverage 10 --is-cross True` |
| `update-isolated-margin` | Transfer isolated margin (HIP-3) | `hl1m update-isolated-margin --coin xyz:GOLD --amount 10` |
### Trading command arguments
#### General rules
1. For `--coin`, always resolve the canonical symbol (use `query-meta` if needed).
2. For `--qty`, use `query-meta` results (e.g. `szDecimals`) to format the quantity precision correctly.
#### `update-isolated-margin`
- `--coin`: required. Canonical symbol.
- `--amount`: required. Transfer amount.
#### `place-order`
- `--coin`: required.
- `--is-buy`: required (True/False). True = long, False = short.
- `--qty`: required.
- `--limit-px`: required.
- `--tif`: optional (`Gtc`/`Ioc`/`Alo`, default `Gtc`).
- `--reduce-only`: optional (default False).
#### `market-order`
- `--coin`: required.
- `--is-buy`: required (True/False). True = long, False = short.
- `--qty`: required.
- `--slippage`: optional (default 0.02 = 2%).
#### `market-close`
- `--coin`: required.
- `--qty`: required.
- `--slippage`: optional (default 0.02 = 2%).
#### `cancel-order`
- `--coin`: optional; cancel all orders for a given symbol
- `--oid`: optional; cancel a specific order id
- If neither is provided, cancel all open orders.
#### `update-leverage`
- `--coin`: required.
- `--leverage`: required (integer).
- `--is-cross`: optional (True/False, default True).
## Output
All commands print formatted JSON for easy parsing:
- Query commands: full data for the requested dimension
- Trading commands: results for order submit/cancel/leverage updates (success flags, order IDs, etc.)
## Error handling
- Network issues: handled by the SDK with error messages
- Invalid trading parameters: returns official Hyperliquid error responses
## Notes
1. Private keys are sensitive. Do not expose or share them.
2. Testnet vs mainnet are strictly separated. Confirm `--testnet` before acting.
3. Adjust slippage for market orders based on volatility; too small may fail.
4. Leverage trading is risky. Choose leverage carefully.
5. For proxy-style setups, follow `hl1m` help for `--address` / `--pri_key` behavior.
## Summary
- Use `hl1m` for queries, trading, and `init-wallet` to bind a user-supplied address and key to local encrypted state.
- Install via `pipx install 1m-trade` (or your package manager); see `hl1m --help` and `reference.md` for full flags.