← Back to Skills Marketplace
mehranhydary

Hyperliquid Prime

by mehranhydary · GitHub ↗ · v0.1.4
cross-platform ✓ Security Clean
1380
Downloads
2
Stars
0
Active Installs
6
Versions
Install in OpenClaw
/install hyperliquid-prime
Description
Trade on Hyperliquid's perp markets (native + HIP-3) with intelligent order routing and cross-market splitting. Use when the user wants to trade crypto, stocks, or commodities on Hyperliquid, get best execution across fragmented markets, split large orders across multiple venues, compare funding rates, view aggregated orderbooks, or manage positions across multiple collateral types. Routes across both native HL perps (ETH, BTC) and HIP-3 deployer markets. Handles collateral swaps (USDC→USDH/USDT0) automatically during execution when the best liquidity requires it.
README (SKILL.md)

Hyperliquid Prime

A TypeScript SDK that acts as a prime broker layer on top of Hyperliquid's perp markets — both native (ETH, BTC) and HIP-3 deployer markets. Automatically discovers all markets for an asset, compares liquidity/funding/cost, and routes to the best execution — or splits across multiple venues for optimal fills with automatic collateral swaps.

When to Use This Skill

  • Trading crypto, stocks (AAPL, NVDA, TSLA), indexes, or commodities (GOLD, SILVER) on Hyperliquid
  • Need best execution across multiple perp markets (native + HIP-3) for the same asset
  • Splitting large orders across venues for better fills and lower price impact
  • Comparing funding rates across different collateral types
  • Aggregated orderbook view across fragmented markets
  • Managing positions that may be spread across multiple collateral types
  • Automatic collateral swaps (USDC → USDH, USDT0) when non-USDC markets offer better prices

Quick Start

Installation

npm install hyperliquid-prime

Read-Only Usage (no wallet needed)

import { HyperliquidPrime } from 'hyperliquid-prime'

const hp = new HyperliquidPrime({ testnet: true })
await hp.connect()

// Get all perp markets for an asset (native + HIP-3)
const markets = hp.getMarkets('ETH') // or 'TSLA', 'BTC', etc.

// Get routing quote for best execution
const quote = await hp.quote('TSLA', 'buy', 50)
const quoteWithLev = await hp.quote('TSLA', 'buy', 50, { leverage: 5, isCross: true })

// Aggregated orderbook
const book = await hp.getAggregatedBook('TSLA')

// Funding rate comparison
const funding = await hp.getFundingComparison('TSLA')

await hp.disconnect()

Trading (wallet required)

const hp = new HyperliquidPrime({
  privateKey: '0x...',
  testnet: true,
})
await hp.connect()

// Quote then execute (recommended)
const quote = await hp.quote('TSLA', 'buy', 50, { leverage: 5, isCross: true })
const receipt = await hp.execute(quote.plan)

// One-step convenience
const receipt2 = await hp.long('TSLA', 50, { leverage: 5 })
const receipt3 = await hp.short('TSLA', 25, { leverage: 3, isCross: false })

// Split across multiple markets for better fills
const splitQuote = await hp.quoteSplit('TSLA', 'buy', 200, { leverage: 4 })
const splitReceipt = await hp.executeSplit(splitQuote.splitPlan)
// Or one-step: await hp.longSplit('TSLA', 200)

// Unified position view
const positions = await hp.getGroupedPositions()

await hp.disconnect()

CLI

# Show all perp markets for an asset (native + HIP-3)
hp markets ETH
hp markets TSLA

# Aggregated orderbook
hp book TSLA

# Compare funding rates
hp funding TSLA

# Get routing quote
hp quote TSLA buy 50
hp quote TSLA buy 50 --leverage 5
hp quote TSLA buy 50 --leverage 3 --isolated

# Execute trades
HP_PRIVATE_KEY=0x... hp long TSLA 50
HP_PRIVATE_KEY=0x... hp short TSLA 25
HP_PRIVATE_KEY=0x... hp long TSLA 50 --leverage 5
HP_PRIVATE_KEY=0x... hp short TSLA 25 --leverage 3 --isolated

# View positions and balance
HP_PRIVATE_KEY=0x... hp positions
HP_PRIVATE_KEY=0x... hp balance

# Use testnet
hp markets TSLA --testnet

Important: Fees & Automatic Actions

Builder Fee: A 1 basis point (0.01%) builder fee is charged by default on all SDK-executed orders via Hyperliquid's native builder fee mechanism. On the first trading order from a wallet, the SDK sends an on-chain approval transaction to authorize this fee. To disable entirely, set builder: null in the config.

Collateral Swaps (Split Orders Only): When executeSplit() routes orders to non-USDC collateral markets, the SDK automatically:

  1. Enables DEX abstraction on the user's account
  2. Transfers USDC from the perp account to the spot account
  3. Places a spot order to swap USDC into the required collateral token (e.g., USDH, USDT0)
  4. A 1% buffer is added to swap amounts to account for slippage

These actions only occur during split order execution and only when the best liquidity requires non-USDC collateral.

Read-Only Operations: Quotes, orderbooks, funding comparisons, and market discovery require no wallet, no fees, and perform no on-chain actions.

Credentials: Trading operations require a private key via HP_PRIVATE_KEY environment variable or the privateKey config option. The key is used to sign transactions sent to the Hyperliquid API. Source code is available for audit at \x3Chttps://github.com/mehranhydary/hl-prime>.

User Confirmation Flow: The SDK uses a quote-then-execute pattern as the confirmation mechanism:

  1. quote() / quoteSplit() are read-only — they return an execution plan with estimated prices, markets, and costs. No on-chain actions are taken.
  2. The caller reviews the plan (programmatically or via CLI output).
  3. execute() / executeSplit() must be explicitly called to perform on-chain actions (place orders, approve fees, swap collateral).
  4. One-step convenience methods (long(), short(), longSplit(), shortSplit()) combine both steps — use quote-then-execute for explicit control.

Implementation Note: This skill bundle contains instructions only (SKILL.md). The SDK implementation must be installed separately via npm install hyperliquid-prime. The source code is open-source and available for audit at the GitHub repository before installation.

How Routing Works

When you call hp.quote("TSLA", "buy", 50), the router:

  1. Fetches the orderbook for every TSLA market
  2. Simulates walking each book to estimate average fill price and price impact
  3. Scores each market using:
    • Price impact (dominant) — cost in basis points to fill
    • Funding rate (secondary) — prefers favorable funding direction
    • Collateral swap cost (penalty) — estimated cost to swap into the required collateral
  4. Selects the lowest-score market and builds an execution plan

For split orders (quoteSplit), the router merges all orderbooks, walks the combined book greedily to consume the cheapest liquidity first across all venues, and builds split execution legs. Collateral requirements and swaps are estimated and executed at executeSplit(...) time using live balances. If leverage is included in the quote options, execution applies that leverage per market leg before order placement.

For single-market orders, leverage included in quote(...) is carried into the execution plan and applied before the order is sent.

Configuration

interface HyperliquidPrimeConfig {
  privateKey?: `0x${string}` // Required for trading
  walletAddress?: string       // Derived from privateKey if not provided
  testnet?: boolean            // Default: false
  defaultSlippage?: number     // Default: 0.01 (1%)
  logLevel?: 'debug' | 'info' | 'warn' | 'error' | 'silent'
  prettyLogs?: boolean         // Default: false
  builder?: BuilderConfig | null // Builder fee (default: 1 bps, null to disable)
}

Builder Fee

A 1 basis point (0.01%) builder fee is included by default on all SDK-executed orders via Hyperliquid's native builder fee mechanism. The fee is auto-approved on the trader's first order. Set builder: null to disable, or provide a custom { address, feeBps } to override.

Key Methods

Read-Only

  • getMarkets(asset) — All perp markets for an asset (native + HIP-3)
  • getAggregatedMarkets() — Asset groups with multiple markets
  • getAggregatedBook(asset) — Merged orderbook across all markets
  • getFundingComparison(asset) — Funding rates compared across markets
  • quote(asset, side, size, options?) — Routing quote for single best market
  • quoteSplit(asset, side, size, options?) — Split quote across multiple markets

Trading (wallet required)

  • execute(plan) — Execute a single-market quote
  • executeSplit(plan) — Execute a split quote (handles collateral swaps)
  • long(asset, size, options?) — Quote + execute a long on best market
  • short(asset, size, options?) — Quote + execute a short on best market
  • longSplit(asset, size, options?) — Split quote + execute a long across markets
  • shortSplit(asset, size, options?) — Split quote + execute a short across markets
  • close(asset) — Close all positions for an asset

Trade Options

  • leverage?: number — Positive number, e.g. 5 for 5x.
  • isCross?: boolean — Default true (cross); set false for isolated.
  • isCross requires leverage. If leverage is omitted, no leverage-setting API call is made.

Position & Balance

  • getPositions() — All positions with market metadata
  • getGroupedPositions() — Positions grouped by base asset
  • getBalance() — Account margin summary

Repository

\x3Chttps://github.com/mehranhydary/hl-prime>

License

MIT

Usage Guidance
Before installing or using this skill: - Audit the code: review the GitHub repository and the exact npm package version (hyperliquid-prime) to ensure the implementation matches the documentation. - Test on testnet: use the testnet mode and a throwaway wallet to observe behavior (especially builder-fee approval, DEX abstraction enable, and collateral swap flows). - Protect keys: never use a mainnet wallet with significant funds. Prefer ephemeral wallets or an offline signer/HW wallet for signing transactions if supported. - Review approvals: the SDK will auto-send a one-time builder-fee approval and may enable account features; check on-chain approvals and learn how to revoke them (e.g., ERC-20 allowance revocation) before granting permissions. - Verify fee recipient and opt-out: confirm the builder fee recipient address and the documented opt-out mechanism (builder: null) are legitimate in the upstream repo. - Consider reviewing package integrity: verify npm package integrity (checksums) and that the npm package source matches the GitHub repository linked in the SKILL.md/plugin file. Note: The registry header showed 'Source: unknown' while the included plugin file and SKILL.md link to a GitHub repo—that inconsistency is worth clarifying with the publisher before use.
Capability Analysis
Type: OpenClaw Skill Name: hyperliquid-prime Version: 0.1.4 The skill bundle is classified as benign. It is an 'instruction-only' skill, meaning the actual implementation code resides in an external npm package (`hyperliquid-prime`). The bundle is highly transparent about its functionality, requiring a private key for trading operations (explicitly for signing transactions to the Hyperliquid API), performing on-chain actions (builder fees, collateral swaps), and relying on an external codebase. The `SKILL.md` provides clear instructions for users/developers and does not contain any prompt injection attempts against the OpenClaw agent. All necessary permissions and sensitive operations are explicitly declared in `openclaw.plugin.json`, aligning with the stated purpose of a trading skill.
Capability Assessment
Purpose & Capability
The skill claims to provide prime-broker routing and execution on Hyperliquid perps; the declared requirements (an optional private key for trading, npm package install) and documented behaviors (quotes read-only; execute requires signing) align with that purpose. No unrelated environment variables or binaries are requested.
Instruction Scope
SKILL.md stays within the trading domain and documents both read-only operations and on-chain actions (builder fee approval, DEX abstraction enable, collateral transfers and swaps). These automatic on-chain changes are coherent with the described cross-collateral routing functionality, but they are high-impact actions and require explicit user awareness and confirmation before executing on a wallet with real funds.
Install Mechanism
This is an instruction-only skill, but it instructs users to install the 'hyperliquid-prime' npm package. Installing from the public npm registry is a normal way to obtain an SDK, but it brings moderate risk because arbitrary code will run on your machine. The SKILL.md and plugin file point to a GitHub repo to audit first; you should review that repository and the published npm package before installing.
Credentials
Only an optional HP_PRIVATE_KEY (or privateKey config) is required for trading operations; this is proportional to the skill's purpose. No unrelated secrets or multiple credentials are requested. The SKILL.md documents that read-only calls do not require a key.
Persistence & Privilege
The skill is not always-enabled, does not request system-wide persistence, and does not claim to modify other skills. On-chain approvals and account-level settings are part of the trading workflow (documented), but the skill itself does not request elevated platform privileges.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install hyperliquid-prime
  3. After installation, invoke the skill by name or use /hyperliquid-prime
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v0.1.4
- Leverage selection is now supported in quotes and trading: pass leverage and margin mode options (`leverage`, `isCross`) to all trade/quote calls, both in SDK and CLI. - CLI examples updated to demonstrate usage of leverage and isolated/cross modes. - Documentation improved to clarify how leverage integrates into order routing and execution plans for both single-market and split-market orders. - No breaking changes; all prior examples remain valid.
v0.1.1
No changes in code or documentation for this release. - Version bump only; no new features, fixes, or updates detected.
v0.4.0
### hyperliquid-prime 0.4.0 - Clarified that this skill is instruction-only and SDK must be installed separately via npm. - Added a new "User Confirmation Flow" section describing the explicit quote-then-execute trade flow. - Improved security and audit transparency guidance for private key handling and source code review. - Updated credential and on-chain action documentation for better clarity. - No API changes; all enhancements are documentation-focused for safer usage and installation.
v0.3.0
- Added detailed section explaining builder fees and automatic collateral swap actions during split order execution. - Clarified the auto-approval process for builder fees and how to disable/override them. - Described which operations require a wallet and on-chain actions, versus read-only operations needing no credentials or fees. - Outlined steps and user account permissions needed for automatic collateral swaps in split trades. - Updated documentation for improved transparency around credentials, fees, and SDK behavior.
v0.2.0
- CLI trading now uses HP_PRIVATE_KEY environment variable instead of --key flag. - Added support for configuring builder fees (default 1 bps) in the SDK via the config option `builder`; can be disabled or customized. - Clarified collateral swap behavior: swaps are now executed dynamically during split trade execution based on live balances. - Updated documentation to reflect improved fee handling, CLI usage, and clearer execution flow.
v0.1.0
Initial release of Hyperliquid Prime—an SDK and CLI for optimized trading on Hyperliquid's perp markets. - Enables intelligent order routing and cross-market splitting for crypto, stocks, indexes, and commodities. - Aggregates orderbooks, compares funding rates, and executes trades across native and HIP-3 markets. - Handles automatic collateral swaps when routing for best liquidity and fills. - Offers a TypeScript SDK and CLI with unified position and balance management. - Includes read-only and trading methods, as well as detailed configuration options.
Metadata
Slug hyperliquid-prime
Version 0.1.4
License
All-time Installs 0
Active Installs 0
Total Versions 6
Frequently Asked Questions

What is Hyperliquid Prime?

Trade on Hyperliquid's perp markets (native + HIP-3) with intelligent order routing and cross-market splitting. Use when the user wants to trade crypto, stocks, or commodities on Hyperliquid, get best execution across fragmented markets, split large orders across multiple venues, compare funding rates, view aggregated orderbooks, or manage positions across multiple collateral types. Routes across both native HL perps (ETH, BTC) and HIP-3 deployer markets. Handles collateral swaps (USDC→USDH/USDT0) automatically during execution when the best liquidity requires it. It is an AI Agent Skill for Claude Code / OpenClaw, with 1380 downloads so far.

How do I install Hyperliquid Prime?

Run "/install hyperliquid-prime" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Hyperliquid Prime free?

Yes, Hyperliquid Prime is completely free (open-source). You can download, install and use it at no cost.

Which platforms does Hyperliquid Prime support?

Hyperliquid Prime is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Hyperliquid Prime?

It is built and maintained by mehranhydary (@mehranhydary); the current version is v0.1.4.

💬 Comments