fix(hyperliquid-plugin): biz-type/strategy attribution + 1-place EVM-012 fix (v0.4.4)#74
Conversation
…012 fix (v0.4.4)
Add `--biz-type dapp --strategy hyperliquid-plugin` to every onchainos
`wallet contract-call` invocation so the OKX backend can attribute
contract calls to this plugin. Source-of-truth for the strategy name
is Cargo.toml's `[package].name` via `env!("CARGO_PKG_NAME")` — no
drift between Cargo.toml, plugin.yaml, plugin.json.
Affected onchainos call sites (5):
- commands/get_gas.rs: USDC approve to relay solver
- commands/get_gas.rs: USDC deposit through relay
- commands/deposit.rs: USDC deposit on Hyperliquid bridge
- commands/evm_send.rs: perp → spot transfer
- commands/evm_send.rs: spot → EVM transfer
Note: hyperliquid's perp order / cancel / TPSL paths use
`onchainos wallet sign-message` (EIP-712), which doesn't accept
biz-type/strategy. Only the contract-call paths can be attributed
under the current onchainos 3.0.0 CLI.
Also fix one real EVM-012 (silent RPC error swallowing):
- commands/get_gas.rs:160 — `erc20_allowance(...).unwrap_or(0)`
silently returned 0 on RPC failure, triggering an unnecessary
re-approve. Changed to fail-closed `match` returning RPC_ERROR
with stdout JSON for the calling Agent.
Other `unwrap_or(0)` sites are JSON-field fallbacks for display-only
fields (positions / orders / spot_prices) and intentional system-clock
fallback in outcome_sell.rs — not real EVM-012.
EVM-006 sleep sites are intentional polling (wait_tx_mined receipt
poll, relay status poll) — these are correct patterns.
Version bump: 0.4.3 → 0.4.4 (PATCH — backwards-compatible).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
🔨 Phase 2: Build Verification — ✅ PASSED
Build succeeded. Compiled artifact uploaded as workflow artifact. Source integrity: commit SHA `` is the content fingerprint. |
📋 Phase 3: AI Code Review Report — Score: 91/100
1. Plugin Overview
Summary: A comprehensive Hyperliquid DEX trading plugin providing perpetuals, spot, HIP-3 builder DEX (RWAs/equities), and HIP-4 outcome (prediction market) trading via the onchainos CLI. Supports order placement, cancellation, position management, deposits/withdrawals, and cross-DEX transfers. Target Users: Traders interested in Hyperliquid perps, RWA markets, and prediction markets through OKX Agentic Wallet integration. 2. Architecture AnalysisComponents: Skill (SKILL.md) + Rust binary Skill Structure: SKILL.md contains pre-flight CI block, command index (~30 commands), HIP-3/HIP-4 architectural notes, error handling, security warnings, and changelog. Comprehensive references to onchainos CLI integration. Data Flow:
Dependencies: 3. Auto-Detected Permissionsonchainos Commands Used
All onchainos commands referenced exist in the provided source code reference. Wallet Operations
External APIs / URLs
Chains Operated On
Overall Permission SummaryThis plugin has very broad financial powers: it can place perpetual orders (with leverage up to 100x), close positions, broadcast Arbitrum→Hyperliquid USDC deposits, withdraw to Arbitrum, transfer between perp/spot, sign 7702/EIP-712 actions, and execute cross-chain swaps via relay.link. All signing is correctly delegated to onchainos (TEE-backed). User confirmation is gated via 4. onchainos API ComplianceDoes this plugin use onchainos CLI for all on-chain write operations?Yes — fully compliant. On-Chain Write Operations (MUST use onchainos)
Data Queries (allowed to use external sources)
External APIs / Libraries DetectedDirect HTTP calls via reqwest to all listed APIs. No private key handling in plugin code — all signing routed through onchainos. Verdict: ✅ Fully CompliantThe plugin correctly delegates ALL signing and broadcasting to onchainos. No private key material handled by plugin. Read-only RPC calls to public endpoints are appropriate for data queries. 5. Security AssessmentStatic Rule Scan (C01-C09, H01-H09, M01-M08, L01-L02)
LLM Judge Analysis (L-PINJ, L-MALI, L-MEMA, L-IINJ, L-AEXE, L-FINA, L-FISO)
Toxic Flow Detection (TF001-TF006)No toxic flows detected. The financial operations (H05) are properly gated with Prompt Injection ScanReviewed SKILL.md for:
Result: ✅ Clean Dangerous Operations CheckThe plugin involves significant financial operations: perps trading (up to 100x leverage), deposits, withdrawals, cross-DEX transfers, contract calls. User confirmation enforcement:
Result: ✅ Safe Data Exfiltration Risk
Result: ✅ No Risk Overall Security Rating: 🟢 Low RiskDespite the high inherent risk of perpetuals trading, the plugin's implementation is exemplary: proper onchainos delegation, explicit 6. Source Code Security (if source code is included)Language & Build Config
Dependency Analysis
All dependencies are standard, well-maintained, and appropriate for the use case. No suspicious or unmaintained packages. Code Safety Audit
Note on Command::new: The plugin shells out to Endpoint declaration check: All URLs in source code (api.hyperliquid.xyz, arbitrum-one-rpc.publicnode.com, rpc.hyperliquid.xyz, api.relay.link, app.hyperliquid.xyz) are declared in plugin.yaml Does SKILL.md accurately describe what the source code does?Yes — SKILL.md command descriptions, parameters, and behavior match source code implementations. The HIP-3/HIP-4 architecture explanation, signing schemes (TEE EIP-712), and fee notes (e.g., $1 USDC withdrawal fee) are accurately reflected in code. Verdict: ✅ Source Safe7. Code ReviewQuality Score: 91/100
Strengths
Issues Found
8. Language Check
9. SUMMARY.md Review
11. Recommendations
12. Reviewer SummaryOne-line verdict: A well-architected, security-conscious Hyperliquid trading plugin with exemplary onchainos integration, comprehensive safety guards, and accurate documentation. Merge recommendation: ✅ Ready to merge Blockers (if any — list every issue that MUST be fixed before merge, each prefixed with ❌): No blockers found. The plugin demonstrates strong security practices: all signing delegated to onchainos TEE, mandatory Generated by Claude AI via Anthropic API — review the full report before approving. |
Summary
Add onchainos 3.0.0 attribution flags
--biz-type dapp --strategy hyperliquid-pluginto everywallet contract-callinvocation. Strategy name reads fromCargo.tomlviaenv!("CARGO_PKG_NAME")to prevent name drift across the 4 metadata files.Also fixes one genuine EVM-012 (silent RPC error swallowing) found during the Step 1.5 scan.
Changes
Attribution (src/onchainos.rs)
Injected into the args of
wallet_contract_call, covering 5 call sites:commands/get_gas.rs× 2 (USDC approve + deposit through relay)commands/deposit.rs(USDC deposit on Hyperliquid bridge)commands/evm_send.rs× 2 (perp ⇄ spot transfers)EVM-012 fix (src/commands/get_gas.rs:160)
Replaced
erc20_allowance(...).unwrap_or(0)with fail-closedmatchreturningRPC_ERRORJSON. The previous behavior silently returned 0 on transient RPC errors, triggering an unnecessary re-approve.Version bump (4 metadata files)
0.4.3 → 0.4.4 (PATCH — backwards-compatible, no API changes).
Out of scope
onchainos wallet sign-message(used for hyperliquid's perp order / cancel / TPSL EIP-712 signing) doesn't accept--biz-type/--strategyin the current onchainos 3.0.0 CLI. Those paths can't be attributed yet.EVM-012 audit
Other
unwrap_or(0)sites scanned and classified:outcome_sell.rs:332— system clock fallback (intentional)spot_prices.rs / orders.rs / positions.rs / order.rs— JSON field fallbacks for display-only fieldsget_gas.rs:160— REAL EVM-012, fixedEVM-006 sleep sites verified as intentional polling patterns (
wait_tx_minedreceipt poll + relay status poll).Test plan
cargo buildpasses (only pre-existing warnings)🤖 Generated with Claude Code