-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmarkets.ts
More file actions
38 lines (32 loc) · 1.03 KB
/
markets.ts
File metadata and controls
38 lines (32 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env npx ts-node
// @ts-nocheck
/**
* Markets Example
*
* List all available markets and HIP-3 DEXes.
*
* No endpoint or private key needed — uses public API.
*/
import { HyperliquidSDK } from '@quicknode/hyperliquid-sdk';
async function main() {
// No endpoint or private key needed for read-only public queries
const sdk = new HyperliquidSDK();
// Get all markets
const markets = await sdk.markets() as { perps?: any[]; spot?: any[] };
const perps = markets.perps || [];
const spot = markets.spot || [];
console.log(`Perp markets: ${perps.length}`);
console.log(`Spot markets: ${spot.length}`);
// Show first 5 perp markets
console.log("\nFirst 5 perp markets:");
for (const m of perps.slice(0, 5)) {
console.log(` ${m.name}: szDecimals=${m.szDecimals}`);
}
// Get HIP-3 DEXes
const dexes = await sdk.dexes() as unknown as any[];
console.log(`\nHIP-3 DEXes: ${dexes.length}`);
for (const dex of dexes.slice(0, 5)) {
console.log(` ${dex.name || 'N/A'}`);
}
}
main().catch(console.error);