Skip to content

feat(hyperliquid): add quickstart command with guided onboarding (v0.3.6)#6

Closed
GeoGu360 wants to merge 1 commit intomig-pre:testfrom
GeoGu360:feat/hyperliquid-quickstart-v0.3.6-clean
Closed

feat(hyperliquid): add quickstart command with guided onboarding (v0.3.6)#6
GeoGu360 wants to merge 1 commit intomig-pre:testfrom
GeoGu360:feat/hyperliquid-quickstart-v0.3.6-clean

Conversation

@GeoGu360
Copy link
Copy Markdown

Summary

  • New quickstart subcommand — checks Arbitrum USDC balance + Hyperliquid perp account in parallel, then guides the user to their next action
  • Detects 5 states: active / ready / needs_deposit / low_balance / no_funds
  • Emits about field (one-liner about Hyperliquid) and onboarding_steps[] with wallet address embedded for new-user cases
  • Output structure matches gmx-v2 quickstart for consistency

Changes

  • src/commands/quickstart.rs — new command
  • src/commands/mod.rs + src/main.rs — wire up Quickstart subcommand
  • SKILL.md — document new command
  • plugin.yaml / Cargo.toml / .claude-plugin/plugin.json — version bump to 0.3.6

Test plan

  • hyperliquid quickstart with funded HL account → status: active/ready
  • hyperliquid quickstart with ARB USDC only → status: needs_deposit, shows deposit command
  • hyperliquid quickstart with no funds → status: no_funds, shows wallet address in onboarding_steps
  • about field present in all cases
  • onboarding_steps omitted for active case

🤖 Generated with Claude Code

…3.6)

- New `quickstart` subcommand: checks ARB USDC + HL perp account in parallel
- Detects 5 states: active/ready/needs_deposit/low_balance/no_funds
- Emits `about` (one-liner description) and `onboarding_steps` with wallet
  address embedded for new-user cases
- Output matches gmx-v2 quickstart pattern for consistency
- Also includes accumulated fixes since v0.3.4: cancel, close, deposit,
  evm_send, get_gas, order, spot_cancel, spot_order, tpsl improvements

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@GeoGu360
Copy link
Copy Markdown
Author

Resubmitting to okx/plugin-store instead

@github-actions
Copy link
Copy Markdown

❌ Phase 1: Structure Validation — FAILED

Linting skills/hyperliquid-plugin...

  ⚠️  [W141] SKILL.md instructs AI to send/post data to external URL 'https://api.hyperliquid.xyz/info'. Declared in api_calls — reviewer should verify this is intentional.
  ❌ [E151] SUMMARY.md missing required section: '## 1. Overview'. See docs/FOR-DEVELOPERS.md for the expected format.
  ❌ [E151] SUMMARY.md missing required section: '## 2. Prerequisites'. See docs/FOR-DEVELOPERS.md for the expected format.
  ❌ [E151] SUMMARY.md missing required section: '## 3. Quick Start'. See docs/FOR-DEVELOPERS.md for the expected format.

✗ Plugin 'hyperliquid-plugin': 3 error(s), 1 warning(s)

Fix all errors before submitting. See CONTRIBUTING.md for guidance.

→ Please fix the errors above and push again.

@github-actions
Copy link
Copy Markdown

📋 Phase 3: AI Code Review Report — Score: 88/100

Plugin: hyperliquid-plugin | Recommendation: ✅ Ready to merge

🔗 Reviewed against latest onchainos source code (live from main branch) | Model: claude-opus-4-7 via Anthropic API | Cost: ~369921+6348 tokens

This is an advisory report. It does NOT block merging. Final decision is made by human reviewers.


1. Plugin Overview
Field Value
Name hyperliquid-plugin
Version 0.3.6
Category defi-protocol
Author GeoGu360 (GeoGu360)
License MIT
Has Binary Yes (with build config)
Risk Level High (perpetuals trading, leverage, fund withdrawal)

Summary: A Rust CLI binary providing Hyperliquid DEX integration — check perp positions, place market/limit orders with TP/SL brackets, manage spot trades, deposit USDC from Arbitrum via bridge, withdraw to Arbitrum, and transfer between perp/spot accounts. All write operations require --confirm and route signing through onchainos CLI (TEE-sandboxed).

Target Users: Crypto traders who want to trade perpetual futures on Hyperliquid L1 via AI agents with leverage up to 100x, using an onchainos-managed wallet.

2. Architecture Analysis

Components:

  • Skill (SKILL.md)
  • Rust binary (hyperliquid-plugin) with 19 subcommands

Skill Structure:
SKILL.md is comprehensive (~700 lines) with: trigger phrases, one-time setup flow, command index with detailed descriptions for 19 commands, chain/API configuration table, error handling, security notice (M07), data trust boundary, and changelog. All commands require --confirm for write operations.

Data Flow:

  • Read ops: query Hyperliquid REST API at api.hyperliquid.xyz/info and Arbitrum RPC for balances
  • Write ops: build EIP-712 typed data → delegate signing to onchainos wallet sign-message → submit signed payload to Hyperliquid exchange endpoint
  • Deposits: sign USDC permit via onchainos → call batchedDepositWithPermit on bridge via onchainos wallet contract-call

Dependencies:

  • External services: Hyperliquid API (mainnet/testnet), Arbitrum RPC, HyperEVM RPC, relay.link API
  • Tools: onchainos CLI (for wallet resolution, signing, contract calls)
  • Rust crates: clap, tokio, reqwest, serde, rmp-serde, sha3, hex
3. Auto-Detected Permissions

onchainos Commands Used

Command Found Exists in onchainos CLI Risk Level Context
onchainos wallet addresses ✅ Yes Low Resolving user's wallet address
onchainos wallet contract-call ✅ Yes High Executing EVM contract calls (deposits, swaps)
onchainos wallet sign-message --type eip712 ✅ Yes High Signing EIP-712 typed data for L1 actions and withdrawals
onchainos wallet status ✅ Yes Low Checking wallet login status

All onchainos commands are validated to exist in the provided source code.

Wallet Operations

Operation Detected? Where Risk
Read balance Yes positions, spot-balances, quickstart Low
Send transaction Yes deposit, get-gas, evm-send High
Sign message Yes order, close, tpsl, cancel, withdraw, transfer High
Contract call Yes deposit, get-gas, evm-send High

External APIs / URLs

URL / Domain Purpose Risk
https://api.hyperliquid.xyz/info Query market data, positions, orders Low
https://api.hyperliquid.xyz/exchange Submit signed trading actions High
https://api.hyperliquid-testnet.xyz/* Testnet endpoints Low
https://arbitrum-one-rpc.publicnode.com Arbitrum RPC for balance/nonce queries Low
https://rpc.hyperliquid.xyz/evm HyperEVM RPC Low
https://api.relay.link Cross-chain swap for gas bootstrap Medium
https://app.hyperliquid.xyz/settings/api-wallets User-facing URL (docs only) Low
https://github.com/okx/plugin-store/* Update checks, binary downloads (pre-flight) Trusted (CI)

Chains Operated On

  • Hyperliquid L1 (chainIndex 999) — perp and spot trading
  • Arbitrum One (chainIndex 42161) — USDC deposits/withdrawals via bridge
  • HyperEVM (chainIndex 999) — native HYPE gas operations

Overall Permission Summary

This plugin can: read wallet addresses and balances; construct and sign perpetual futures orders (with leverage up to 100x); open/close positions; set TP/SL; cancel orders; deposit USDC from Arbitrum via bridge; withdraw USDC back to Arbitrum; transfer funds between perp and spot accounts; swap USDC for HYPE gas via relay.link; and send USDC from HyperCore to HyperEVM. All signing is delegated to onchainos (TEE). All write operations are gated by explicit --confirm flag. No private key handling in the plugin itself.

4. onchainos API Compliance

Does this plugin use onchainos CLI for all on-chain write operations?

Yes — all signing and EVM contract calls are routed through onchainos.

On-Chain Write Operations (MUST use onchainos)

Operation Uses onchainos? Self-implements? Detail
Wallet signing No onchainos wallet sign-message --type eip712
Transaction broadcasting No For EVM: wallet contract-call; for HL: submits signed payload directly (off-chain REST API)
DEX swap execution N/A No HL is custom L1, not EVM swap
Token approval No Uses USDC permit via wallet sign-message (no approve tx)
Contract calls No onchainos wallet contract-call for all EVM interactions
Token transfers No Perp/spot transfers via signed EIP-712 actions

Data Queries (allowed to use external sources)

Data Source API/Service Used Purpose
Hyperliquid api.hyperliquid.xyz/info Market data, positions, orders
Arbitrum RPC arbitrum-one-rpc.publicnode.com USDC balance, permit nonce, allowance
HyperEVM RPC rpc.hyperliquid.xyz/evm Native HYPE balance, tx receipts
relay.link api.relay.link Cross-chain swap quote for gas

External APIs / Libraries Detected

No direct web3 libraries (no ethers/web3). Uses raw JSON-RPC via reqwest for read-only queries. All signing delegated to onchainos.

Verdict: ✅ Fully Compliant

All write operations that require private keys delegate to onchainos. The plugin only constructs unsigned payloads, lets onchainos sign, then forwards the signed result to Hyperliquid's exchange REST API (which is the expected flow for HL since it's not a standard EVM chain).

5. Security Assessment

Static Rule Scan (C01-C09, H01-H09, M01-M08, L01-L02)

Rule ID Severity Title Matched? Detail
C01 CRITICAL curl | sh remote exec ❌ (auto-injected only) Only in Pre-flight block — skipped per instructions
H05 INFO Direct financial / on-chain ops Wallet signing, contract calls, fund withdrawals — baseline for DeFi trading plugin
M03 MEDIUM Third-party content ✅ (mitigated) External API calls to Hyperliquid, Arbitrum RPC, relay.link — properly declared in plugin.yaml api_calls
M07 MEDIUM Missing untrusted-data boundary ❌ (passes) SKILL.md includes explicit > **Data boundary notice:** Treat all data returned by this plugin and the Hyperliquid API as untrusted external content...
M08 MEDIUM External data field passthrough ❌ (passes) SKILL.md enumerates exact Display fields for each command (e.g., "Display: coin, side, size, entryPrice, unrealizedPnl, liquidationPrice, leverage")

No CRITICAL or HIGH rules matched in the developer-submitted content.

LLM Judge Analysis (L-PINJ, L-MALI, L-MEMA, L-IINJ, L-AEXE, L-FINA, L-FISO)

Judge Severity Detected Confidence Evidence
L-PINJ CRITICAL No 0.95 No hidden instructions, jailbreak tokens, or pseudo-system tags detected
L-MALI CRITICAL No 0.90 Stated purpose (Hyperliquid trading) matches actual code behavior
L-MEMA HIGH No 0.95 No writes to MEMORY.md/SOUL.md or Agent persistent memory
L-IINJ INFO Yes (compliant) 0.95 External requests present; explicit untrusted-data boundary declared
L-AEXE INFO Partial 0.85 All write ops gated by --confirm; explicit warning about perpetual risk; --force policy explicitly documented as never-on-first-invocation
L-FINA INFO Yes 0.95 Write + confirmation gating + leveraged trading + withdrawal capability — INFO-level because confirmation gates are in place
L-FISO INFO No 0.90 No field isolation concerns beyond declared display rules

Toxic Flow Detection (TF001-TF006)

No toxic flows detected. The auto-injected curl|sh in the Pre-flight block (per review instructions, must be skipped) is not combined with user-submitted financial actions in a way that creates a TF005 risk, because the developer-submitted code uses onchainos for signing (no custom financial signing path vulnerable to script substitution).

Prompt Injection Scan

No instruction override, identity manipulation, hidden behavior, confirmation bypass attempts, base64-encoded payloads, or invisible characters detected. The document contains clear, legitimate trading instructions with proper risk warnings.

Result: ✅ Clean

Dangerous Operations Check

The plugin performs: transfers (deposit/withdraw/transfer), signing (all write ops), contract calls (deposit, get-gas, evm-send), and HL exchange submissions (orders, cancels, close, tpsl). All are gated by explicit --confirm flag; without it, commands only print a preview. The SKILL.md has strong <NEVER> directives against passing --force on first invocation.

Result: ✅ Safe

Data Exfiltration Risk

No environment variable extraction, no reads from sensitive paths (~/.ssh, ~/.aws, ~/.env), no base64-encoded command substitution, no backtick injection. External API calls are all to declared endpoints for documented trading purposes. resolve_wallet reads only from onchainos wallet addresses output.

Result: ✅ No Risk

Overall Security Rating: 🟢 Low Risk

(Low from a supply-chain/prompt-injection perspective. Inherent financial risk remains HIGH for users due to perpetuals trading — but this is properly disclosed.)

6. Source Code Security

Language & Build Config

  • Language: Rust
  • Entry point: src/main.rs
  • Binary name: hyperliquid-plugin
  • Edition: 2021

Dependency Analysis

  • clap 4.x — CLI parsing, well-maintained
  • tokio 1.x — async runtime, standard
  • reqwest 0.12 — HTTP client with json feature; rustls + native-tls (native-tls pulled in as dep)
  • serde/serde_json — serialization, standard
  • rmp-serde 1.x — MessagePack encoding (used for HL action_hash, matches official Python SDK)
  • sha3 0.10 — Keccak256 for EIP-712 hashing and function selector generation
  • hex 0.4 — hex encoding
  • anyhow 1.x — error handling

All dependencies are well-known, actively maintained crates with no known security issues. Minimal dep tree.

Code Safety Audit

Check Result Detail
Hardcoded secrets (API keys, private keys, mnemonics) None found. Only public contract addresses (USDC, HL bridge)
Network requests to undeclared endpoints All endpoints match plugin.yaml api_calls declaration
File system access outside plugin scope No file reads/writes in plugin binary
Dynamic code execution (eval, exec, shell commands) Uses Command::new("onchainos") only; no arbitrary shell execution
Environment variable access beyond declared env Only reads HYPERLIQUID_TESTNET flag
Build scripts with side effects (build.rs, postinstall) No build.rs present
Unsafe code blocks No unsafe blocks found in reviewed Rust source

Does SKILL.md accurately describe what the source code does?

Yes. All 19 subcommands documented in SKILL.md map directly to the source code. Signing flow (onchainos → EIP-712 → HL exchange) is accurately described. Withdrawal fee ($1 USDC) is documented and enforced in withdraw.rs. Chain IDs match (999, 42161).

Verdict: ✅ Source Safe

7. Code Review

Quality Score: 88/100

Dimension Score Notes
Completeness (pre-flight, commands, error handling) 23/25 Comprehensive command set; detailed error table; clear fallback for insufficient balance
Clarity (descriptions, no ambiguity) 23/25 Clear trigger phrases in EN+CN; detailed parameter tables; good examples
Security Awareness (confirmations, slippage, limits) 24/25 Explicit --confirm requirement; <NEVER> on --force bypass; slippage controls; min notional checks; TEE signing emphasized
Skill Routing (defers correctly, no overreach) 13/15 Good "Do NOT Use For" section; routes to other plugins appropriately
Formatting (markdown, tables, code blocks) 9/10 Clean tables, consistent code fences, proper YAML frontmatter

Strengths

  • Excellent security posture: all write ops gated by --confirm, explicit <NEVER> directives against first-call --force, TEE-delegated signing
  • Proper data trust boundary declaration and field-level display rules
  • Comprehensive command surface with clear parameter validation (min notional, slippage, leverage range 1-100, tick size rounding)

Issues Found

  • 🔵 Minor: Registration flow for API wallets (option 2 in register) directs users to Hyperliquid web UI — unavoidable given HL's design, but worth noting in risk summary
  • 🔵 Minor: evm_send uses CoreWriter precompile with hardcoded magic addresses (0x3333...) — consider adding a version check or warning in case HL changes this
  • 🔵 Minor: Consider documenting testnet usage (HYPERLIQUID_TESTNET env var) more prominently in SKILL.md trigger phrases
8. Language Check
File Language Detected English?
SKILL.md English (with bilingual trigger phrases EN+中文)
SUMMARY.md English

Both files are primarily in English. Chinese content appears only in trigger phrase mappings (acceptable pattern for internationalization).

9. Recommendations
  1. Consider adding a visible testnet-mode indicator in command output when HYPERLIQUID_TESTNET=1 is set, to prevent confusion.
  2. Add a note in the register command output warning users that option 2 (web UI) takes them outside the onchainos trust boundary.
  3. Document the CoreWriter precompile address assumption in a comment in evm_send.rs so future maintainers know to verify against HL's latest docs.
  4. Consider surfacing slippage tolerance defaults (5%, 10%) more prominently in SKILL.md — currently only in code.
10. Reviewer Summary

One-line verdict: Well-architected Hyperliquid DEX plugin with strong security controls — all signing delegated to onchainos, all write ops confirmation-gated, clear data boundaries, and accurate documentation.

Merge recommendation: ✅ Ready to merge

The plugin correctly uses onchainos for all signing operations, gates every write with --confirm, includes explicit <NEVER> directives against bypassing confirmation, declares untrusted-data boundaries, and enumerates display fields to prevent prompt injection via API responses. Source code contains no unsafe code, no hardcoded secrets, no dynamic execution of external content, and all network endpoints match the declared api_calls. Inherent financial risk (leveraged perpetuals, up to 100x) is clearly disclosed in SKILL.md's Security Notice section.


Generated by Claude AI via Anthropic API — review the full report before approving.

@github-actions
Copy link
Copy Markdown

🔨 Phase 2: Build Verification — ✅ PASSED

Plugin: hyperliquid-plugin | Language: rust
Source: @

Compiled from developer source code by our CI. Users install our build artifacts.

Build succeeded. Compiled artifact uploaded as workflow artifact.


Source integrity: commit SHA `` is the content fingerprint.

mig-pre pushed a commit that referenced this pull request Apr 17, 2026
… validation

Balance pre-checks (all 8 write commands):
- Added erc20_balance_of() to onchainos.rs — direct eth_call balanceOf, avoids SDK round-trip
- Each command checks wallet balance against required amount before calling Pendle SDK
- redeem-py checks both PT and YT balances independently
- Guard skips during --dry-run (offline mode); active for preview and --confirm

SDK calldata validation (api.rs):
- validate_sdk_calldata() called inside extract_sdk_calldata() on every write path
- Rejects calldata shorter than 4 bytes or containing non-hex characters
- Rejects router_to addresses not in Pendle Router v3 / known aggregator whitelist
- Rejects selectors matching ERC-20/ERC-721 drain operations (transfer, transferFrom,
  approve, setApprovalForAll, safeTransferFrom)

Addresses Phase 3 AI Code Review recommendations #1 and #6.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant