The Hyperliquid Adapter provides a standardized interface to Hyperliquid's perpetual futures exchange, enabling INTUE agents to execute trades, manage perpetual positions, and access market data with minimal latency.
const hyperliquidAdapter = new HyperliquidAdapter({
apiKey: 'YOUR_API_KEY',
secretKey: 'YOUR_SECRET_KEY',
testnet: false // Set to true for testing
});
Key Features
Zero Gas Fee Trading: Leverage Hyperliquid's gas-free transaction model
Perpetual Futures Focus: Specialized for derivatives trading with up to 50x leverage
Cross-Margin Support: Unified margin across all positions
Sub-second Execution: Optimized for high-frequency trading strategies
On-Chain Order Book: Fully transparent and verifiable trade execution
Setup and Configuration
Authentication
// Initialize with API credentials
const hyperliquid = new HyperliquidAdapter({
apiKey: process.env.HYPERLIQUID_API_KEY,
secretKey: process.env.HYPERLIQUID_SECRET_KEY,
webSocketEnabled: true
});
// Test connection
const status = await hyperliquid.getConnectionStatus();
console.log(`Connected to Hyperliquid: ${status.connected}`);
Environment Configuration
The adapter supports both mainnet and testnet environments:
// For testnet (paper trading)
const testHyperliquid = new HyperliquidAdapter({
apiKey: process.env.HYPERLIQUID_TESTNET_API_KEY,
secretKey: process.env.HYPERLIQUID_TESTNET_SECRET_KEY,
testnet: true
});
Core Functionality
Market Data
// Get available markets
const markets = await hyperliquidAdapter.getMarkets();
// Get current price
const price = await hyperliquidAdapter.getCurrentPrice('BTC-PERP');
// Get order book
const orderBook = await hyperliquidAdapter.getOrderBook('ETH-PERP', 10); // depth of 10
// Get funding rates
const fundingRates = await hyperliquidAdapter.getFundingRates();
Account Management
// Get account information
const account = await hyperliquidAdapter.getAccountInfo();
// Get available margin
const margin = await hyperliquidAdapter.getAvailableMargin();
// Get account leverage
const leverage = await hyperliquidAdapter.getLeverage();
// Set account leverage
const newLeverage = await hyperliquidAdapter.setLeverage(10); // 10x
Position Management
// Get open positions
const positions = await hyperliquidAdapter.getPositions();
// Get position for specific asset
const ethPosition = await hyperliquidAdapter.getPosition('ETH-PERP');