Perp DEX All-In-One SDK - Unified TypeScript SDK for Decentralized Perpetual Exchanges
νκ΅μ΄ λ¬Έμ | English
PD AIO SDK (Perp DEX All-In-One SDK) is a production-ready, unified TypeScript SDK that lets you trade on 7 decentralized perpetual exchanges through a single, consistent interface. No more learning different APIs for each exchange - write once, trade anywhere.
- One Interface β 7 Exchanges (Hyperliquid, GRVT, Paradex, EdgeX, Backpack, Lighter, Nado)
- One Codebase β All Trading Operations (market data, orders, positions, WebSocket)
- One Installation β Full-Stack Solution (authentication, rate limiting, error handling)
- CCXT-style API - Familiar interface for developers
- Fully Async/Await - All methods return Promises, no callbacks
- Consistent method names across all exchanges
- Python aliases available (snake_case for Python developers)
- Hyperliquid - Production + Testnet, 200k orders/sec, HIP-3 ecosystem
- GRVT - Production + Testnet, Hybrid CEX/DEX, portfolio margin
- Paradex - Production + Testnet (Sepolia), StarkNet L2
- EdgeX - Production only (V1), Sub-10ms matching, $130B+ volume
- Backpack - Production only, Solana-based, multi-market support
- Lighter - Beta + Testnet, ZK-SNARK proofs, orderbook DEX
- Nado - Production + Testnet, Ink L2 by Kraken, 5-15ms latency
- EIP-712 signatures (Hyperliquid, GRVT, Nado)
- StarkNet ECDSA (Paradex, EdgeX)
- ED25519 (Backpack)
- API Key authentication (Lighter)
- Secure credential management with validation
- WebSocket streaming - Real-time order books, positions, trades
- Auto-reconnection - Exponential backoff with subscription recovery
- Rate limiting - Exchange-specific limits respected automatically
- Smart caching - Market data caching with configurable TTL
- Retry logic - Automatic retry with exponential backoff
- Type safety - Runtime validation (Zod) + TypeScript strict mode
- Pattern A Architecture - All 7 adapters follow standardized structure
- 409 tests - 100% pass rate, production-ready
- Structured logging - JSON logs with sensitive data masking
- Health checks - Built-in system monitoring
- Comprehensive docs - English + Korean documentation
- TypeScript strict mode - Full type safety
- Examples included - 10+ ready-to-use examples
npm install pd-aio-sdk
# or
yarn add pd-aio-sdk
# or
pnpm add pd-aio-sdkimport { createExchange, createSymbol } from 'pd-aio-sdk';
import { Wallet } from 'ethers';
// Initialize adapter
const wallet = new Wallet(process.env.PRIVATE_KEY);
const exchange = createExchange('hyperliquid', {
wallet,
testnet: true
});
await exchange.initialize();
// Create a symbol (exchange-aware)
const symbol = createSymbol('hyperliquid', 'BTC'); // Returns "BTC/USDT:USDT"
// Fetch market data
const markets = await exchange.fetchMarkets();
const orderBook = await exchange.fetchOrderBook(symbol);
const ticker = await exchange.fetchTicker(symbol);
// Place an order
const order = await exchange.createOrder({
symbol,
type: 'limit',
side: 'buy',
amount: 0.1,
price: 50000
});
// Check positions
const positions = await exchange.fetchPositions();
const balances = await exchange.fetchBalance();
// Cancel order
await exchange.cancelOrder(order.id, symbol);
// Cleanup
await exchange.disconnect();| Exchange | Status | Testnet | Auth Method | Architecture | Special Features |
|---|---|---|---|---|---|
| Hyperliquid | β Production | β Public | EIP-712 | Pattern A | 200k orders/sec, HIP-3 ecosystem, faucet available |
| GRVT | β Production | β Public | EIP-712 + Session | Pattern A | Hybrid CEX/DEX, portfolio margin |
| Paradex | β Production | β Public (Sepolia) | StarkNet + JWT | Pattern A | StarkNet L2, ultra-low latency |
| EdgeX | β Production (V1) | β Mainnet only* | StarkEx + Pedersen | Pattern A | Sub-10ms matching, $130B+ volume |
| Backpack | β Production | β Mainnet only | ED25519 | Pattern A | Solana-based, multi-market types |
| Lighter | β Public (ETH testnet) | API Key | Pattern A | ZK-SNARK proofs, orderbook DEX | |
| Nado | β Production | β Public (Ink L2) | EIP-712 | Pattern A | Ink L2 by Kraken, 5-15ms latency |
*EdgeX V2 testnet planned for Q3 2025
All HIP-3 DEXs share Hyperliquid's infrastructure - one adapter, 7+ platforms:
- trade.xyz - US stock perpetuals (NVDA, TSLA, AAPL)
- Ventuals - Pre-IPO perps (SpaceX, OpenAI, Anthropic)
- Based - Trading super app
- Volmex - Volatility indices
- Nunchi - Yield/APY perpetuals
- Aura - US Treasury perps
# Copy example file
cp .env.example .env# Hyperliquid (EIP-712)
HYPERLIQUID_PRIVATE_KEY=0x1234...
HYPERLIQUID_TESTNET=true
# GRVT (EIP-712 + Session)
GRVT_PRIVATE_KEY=0x1234...
GRVT_API_KEY=your_api_key
GRVT_TESTNET=true
# Paradex (StarkNet)
PARADEX_PRIVATE_KEY=0x1234...
PARADEX_ACCOUNT_ADDRESS=0x5678...
PARADEX_TESTNET=true
# Backpack (ED25519)
BACKPACK_PRIVATE_KEY=base58_encoded_key
BACKPACK_TESTNET=true
# Lighter (API Key)
LIGHTER_API_KEY=your_api_key
LIGHTER_API_SECRET=your_api_secret
LIGHTER_ACCOUNT_ID=your_account_id
# EdgeX (StarkEx)
EDGEX_API_KEY=your_api_key
EDGEX_TESTNET=trueimport { validateConfig } from 'pd-aio-sdk';
try {
validateConfig('hyperliquid');
console.log('β
Configuration valid');
} catch (error) {
console.error('β Configuration error:', error.message);
}import { createExchange } from 'pd-aio-sdk';
const exchange = createExchange('hyperliquid', {
wallet: new Wallet(process.env.PRIVATE_KEY),
testnet: true
});
await exchange.initialize();
// Stream order book updates
for await (const orderBook of exchange.watchOrderBook('BTC/USDT:USDT')) {
console.log('Best bid:', orderBook.bids[0]);
console.log('Best ask:', orderBook.asks[0]);
}
// Stream position updates
for await (const positions of exchange.watchPositions()) {
console.log('Positions updated:', positions);
}
// Stream trades
for await (const trade of exchange.watchTrades('BTC/USDT:USDT')) {
console.log('New trade:', trade);
}import { createExchange, withRetry } from 'pd-aio-sdk';
const exchange = createExchange('hyperliquid', { testnet: true });
// Automatic retry on transient failures
const markets = await withRetry(
() => exchange.fetchMarkets(),
{
maxAttempts: 3,
initialDelay: 1000,
backoffMultiplier: 2,
maxDelay: 10000
}
);import { createSymbol } from 'pd-aio-sdk';
// Exchange-aware symbol creation
const btcHyper = createSymbol('hyperliquid', 'BTC'); // "BTC/USDT:USDT"
const ethGrvt = createSymbol('grvt', 'ETH'); // "ETH/USDT:USDT"
const solBack = createSymbol('backpack', 'SOL'); // "SOL/USDT:USDT"
// Custom quote currency
const btcUsdc = createSymbol('paradex', 'BTC', 'USDC'); // "BTC/USDC:USDC"// TypeScript style
await exchange.fetchOrderBook('BTC/USDT:USDT');
await exchange.createOrder({ ... });
// Python style (snake_case)
await exchange.fetch_order_book('BTC/USDT:USDT');
await exchange.create_order({ ... });import { createExchange } from 'pd-aio-sdk';
const exchange = createExchange('hyperliquid', { testnet: true });
await exchange.initialize();
// Check health
const health = await exchange.getHealth();
console.log('Status:', health.status); // 'healthy' | 'degraded' | 'unhealthy'
console.log('Uptime:', health.uptimeSeconds);
console.log('Cache hit rate:', health.cache.hitRate);All 7 exchange adapters now follow Pattern A (Full-Featured) architecture - a standardized, consistent structure that provides:
- β Dedicated Normalizer classes for data transformation
- β Separation of concerns between adapter logic and normalization
- β Enhanced testability with isolated unit tests
- β Consistent file structure across all adapters
- β Better maintainability and easier onboarding
Each adapter follows this standardized structure:
src/adapters/{exchange}/
βββ {Exchange}Adapter.ts # Main adapter implementation
βββ {Exchange}Normalizer.ts # Data transformation (all 7 adapters)
βββ {Exchange}Auth.ts # Authentication (complex auth only)
βββ utils.ts # Helper functions
βββ constants.ts # Configuration
βββ types.ts # TypeScript types
βββ index.ts # Public API
Example: Using a Normalizer class directly
import { HyperliquidNormalizer } from 'pd-aio-sdk/adapters/hyperliquid';
const normalizer = new HyperliquidNormalizer();
const unifiedSymbol = normalizer.normalizeSymbol('BTC-PERP');
// Returns: 'BTC/USDT:USDT'βββββββββββββββββββββββββββββββββββββββββββββββ
β Application Layer β
β (Your Trading Bot / Application) β
ββββββββββββββββββ¬βββββββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββ
β PD AIO SDK - Unified Interface β
β ββββββββββββββββββββββββββββββββββββββββ β
β β Common Types & Interfaces β β
β β - IExchangeAdapter β β
β β - Unified Order/Position/Balance β β
β ββββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββ¬βββββββββββββββββββββββββββββ
β
ββββββββββββββΌβββββββββββββ
βΌ βΌ βΌ
βββββββββββ βββββββββββ βββββββββββ
βHyperliquid βGRVT βParadex β ...
βAdapter βAdapter βAdapter β
β + β + β + β
βNormalizerβNormalizerβNormalizerβ
βββββββββββ βββββββββββ βββββββββββ
β β β
βΌ βΌ βΌ
βββββββββββββββββββββββββββββββββββββββββββββββ
β Exchange APIs β
β (Hyperliquid, GRVT, Paradex, etc.) β
βββββββββββββββββββββββββββββββββββββββββββββββ
- Adapters - Exchange-specific implementations (Pattern A)
- Normalizers - Data transformation classes (all 7 adapters)
- Core - Rate limiting, retry logic, logging, health checks
- WebSocket - Connection management, auto-reconnection
- Utils - Symbol helpers, validation, error mapping
- Types - Unified data structures, error hierarchy
Learn More: See ARCHITECTURE.md for detailed architecture documentation
# All tests
npm test
# With coverage
npm run test:coverage
# Watch mode
npm run test:watch
# Specific exchange
npm test -- hyperliquidβ
395 tests passing (100% pass rate)
β
22 test suites
β
Integration tests: 17/17
β
Unit tests: 378/378
# Install dependencies
npm install
# Build TypeScript
npm run build
# Watch mode
npm run dev
# Lint
npm run lint
# Format
npm run format
# Type check
npm run typecheckWe welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'feat: add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
MIT License - see LICENSE file for details.
- Architecture: ARCHITECTURE.md - Detailed architecture guide
- API Reference: API.md - Complete API documentation
- Adapter Guide: ADAPTER_GUIDE.md - Guide for adding new exchanges
- Contributing: CONTRIBUTING.md - Development guidelines
- Changelog: CHANGELOG.md - Version history
- Korean Docs: νκ΅μ΄ λ¬Έμ - Korean documentation
- Exchange Guides: docs/guides/ - Exchange-specific documentation
- Examples: examples/ - Ready-to-use code examples
- API Audit: API Implementation Audit
- Inspired by CCXT unified API design
- Built with ethers.js, starknet.js
- Thanks to all exchange teams for comprehensive API documentation
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Built with β€οΈ for the DeFi community